Condition element (WorkflowInfo)

Applies to: SharePoint 2016 | SharePoint Foundation 2013 | SharePoint Online | SharePoint Server 2013

Represents a Condition statement, which is part of a rule sentence that can be displayed in a declarative, rules-based, code-free workflow editor, such as Microsoft SharePoint Designer 2010.

When a workflow is triggered by an event that corresponds to a SharePoint list or document library item in Microsoft SharePoint Foundation 2010, it is often necessary to evaluate what workflow action should be taken or if an action is required. A Condition element allows the workflow to perform this evaluation with the values and arguments that are provided to it by the workflow editor.

Each Condition element also corresponds to a Boolean method inside a specified SharePoint Foundation 2010 workflow library. These methods are used to evaluate values passed by their parameters and return either true or false.

A Condition element contains information about the Microsoft .NET assembly where the Condition code is implemented, and also the parameters that are required to make the function call. It also contains information about how the Condition statement should be displayed to the workflow editor.

Definition

<WorkflowInfo>
      <Conditions>
            <Condition>
               <RuleDesigner>…</RuleDesigner>
               <Paramaters>…</Parameters>
            </Condition>
            <Default>…</Default>
      </Conditions>
      <Action>…</Actions>
</WorkflowInfo>

Elements and attributes

The following sections describe attributes, child elements, and parent elements.

Attributes

Attribute

Description

**AppliesTo**

Required **text**. Specifies that the conditional statement that is being evaluated is applied to a SharePoint list or document library. By changing the value, you can show or hide a specific condition statement in the workflow editor, depending on the type of SharePoint list that the workflow is associated with.

The following values are not case-sensitive:

  • **all**   specifies that a condition statement is available to all list and document library types.

  • **doclib**   specifies that a condition statement is visible to the workflow editor only when the workflow is associated with a document library. If the workflow is associated with any other type of list, the condition statement is hidden from the workflow editor.

  • **list**   specifies that a condition statement is visible to the workflow editor only when the workflow is associated with a SharePoint list. If the workflow is associated with any type other than a list type, the condition statement is hidden from the workflow editor.

  • **none**   specifies that a condition statement is hidden from the workflow editor.

**Assembly**

Required **text**. Specifies the .NET assembly that contains the implementation code for the **Condition** element.

Value type: **String**.

Specifies the .NET assembly that contains the workflow code. The format should be as follows:

Assembly name, Version, Culture, PublicKeyToken

Example:

Assembly=>Microsoft.SharePoint.WorkflowActions,

                Version=12.0.0.0,

                Culture=neutral,

                PublicKeyToken= 71e9bce111e9429c>

**ClassName**

Required **text**. Contains the fully qualified class name in which the **Condition** element code is implemented.

Value type: **String**.

Fully qualified class name in which the custom **Condition** element code is implemented.

Example:

**XML**:

ClassName=>**Microsoft.SharePoint.WorkflowActions.Helper**>

**FunctionName**

Required **text**. Name of the **Boolean** method in the class that implements the **Condition** code.

Value type: **String**.

Represents the method name in the class in which the **Condition** element code is implemented.

**Example method**:

`Bool myCondition(WorkflowContext context, string ListGUIDorName, int ItemWorkflowAttachedTo)`

**XML**:

FunctionName=>myCondition>

**ItemKeyType**

Optional **text**. The implementation-specific identifier for the default object type.

**Name**

Required **text**. Specifies a localized condition name.

**Type**

Optional **text**. Specifies whether the **Condition** element is **Custom** or **Advanced**.

The following values are not case-sensitive:

  • **Custom**   Used to compare a value found in the current SharePoint list or document library item to a value specified by the workflow designer.

  • **Advanced**   Used to indicate that a **Condition** can be used to compare two values of any type (for example, text, integers, and dates).

**UsesCurrentItem**

Optional **Boolean**. Specifies that the item currently selected is associated with the workflow.

Value type: **Boolean**.

If set to **true**, the workflow binds to the SharePoint list item or document library item that started the workflow instance. When using a declarative, code-free workflow editor, this value always returns **true **and cannot be changed.

Child elements

RuleDesigner

Parameters

Parent elements

Conditions

Example

The following example shows how to expose a Condition element to the code-free editor during the workflow design process.

    <WorkflowInfo Language="en-us">
       <Conditions And="and" Or="or" Not="not" When="If" Else="ElseIf">
          <Condition
                  AppliesTo="list"
                  Assembly="MyWorkflowProject.Workflow1,
                            PublicKeyToken=71e9bce111e9429c,
                            Version=1.0.0.0,
                            Culture=neutral"
                  ClassName="MyWorkflowProject.Workflow1.MyClass"
                  FunctionName="IsOrderComplete"
                  Name="Check if item in %1 is a complete order"
                  Type="Custom"
                  UsesCurrentItem="True">
              <RuleDesigner>...</RuleDesigner>
          </Condition>
       </Conditions>
    </WorkflowInfo>

See also