SharePoint Designer 2013 workflow If-Else condition

Learn how you can add an If-Else condtion to a SharePoint Designer 2013 workflow.

ADVERTISEMENTS

You can use If-Else conditions in a workflow to direct the flow of execution of actions within a workflow just like you would use If-Else conditions in a programming language.

In SharePoint Designer 2013, you must first add an If condition to the workflow, and then afterwards you can add an Else branch to an If condition to create an If-Else condition. The latter is demonstrated in this tutorial.

Here, you will use SharePoint Designer 2013 to create a site workflow that accepts a number, and then writes a message to the workflow history list depending on whether that number is greater than 30 or not, thereby using an If-Else condition in the workflow.

Before you begin, ensure that you have gone through the tutorial to create a simple workflow in SharePoint Designer 2013, so that you know how to add actions to and publish a workflow.

To add an If-Else condition to a SharePoint Designer 2013 workflow

  1. Follow the steps 1 through 4 described in Create and start a SharePoint Designer 2013 site workflow to create a simple site workflow.
  2. Add an initiation parameter named YourAge of type Number (1, 1.0, 100) as described in Pass a value to a SharePoint Designer 2013 site workflow to the workflow.
  3. Click to place the cursor in Stage 1, and then click Workflows > Insert > Condition and select If any value equals value from the drop-down menu that appears.
  4. Click the first value in the sentence for the workflow action, and then click the formula button behind the text box that appears.
  5. On the Define Workflow Lookup dialog box, select Workflow Variables and Parameters from the Data source drop-down list box, select Parameter: YourAge from the Field from source drop-down list box, and click OK.
  6. Click equals in the sentence for the workflow action, and select is greater than from the drop-down list box that appears.
  7. Click the second value in the sentence for the workflow action, and then type 30 in the text box that appears.
  8. Add a Log to History List action under the If statement and configure the action to write You are old! as a message to the history list.
  9. Click to place the cursor below the last action, and then click Workflows > Insert > Else Branch.
  10. Add a Log to History List action to the Else branch and configure it to write You are very young! as a message to the history list.
  11. Add a Go to a stage action in the Transition to stage section of Stage 1, and then select to go to End of Workflow.
  12. Publish the workflow to SharePoint.

In SharePoint 2013, test the site workflow by starting it and passing a number to it at startup (also see Pass a value to a SharePoint Designer 2013 site workflow). Verify that the correct messages have been written to the workflow history list.

Still unclear? Watch the SharePoint 2013 video tutorial below.

Related Articles

ADVERTISEMENTS