How To: Use a SharePoint Reference to Conditional Start a Workflow

  • This content uses the legacy Nintex K2 for SharePoint app. For more information about using the new Nintex Automation for SharePoint app, see Adding the App.

This topic shows you how to use a SharePoint library reference to configure a rule which determines if a workflow should start. You use a Conditional Start Rule to define this logic, and the data comes from the document in a SharePoint library using the automatically-created reference. You configure the Conditional Start Rule on the Start step and build it using the Rules Designer.

This example assumes that you are familiar with K2 for SharePoint.

Using a conditional start rule to start a workflow when a purchase order document is added to the wrong library

Scenario

You use SharePoint document libraries to store team documents. You have two libraries called General Documents and Purchase Orders. These two libraries are not integrated with K2 for SharePoint. Purchase orders must be stored in the Purchase Orders library where the Finance department stores them. All other documents are stored in the General Documents library. Sometimes documents are uploaded to the wrong library, with purchase orders stored in the General Document library. In these cases, someone should be notified that documents are in the wrong library.

For this scenario, you want a workflow to start when Purchase Orders are added to the General Documents library. You are not concerned about the other types of documents, just Purchase Orders. The workflow only starts if the condition, set in the rule, is met. In this case, the workflow starts if the Name field contains the words Purchase Order.

Steps

In this scenario, you begin by creating two SharePoint document libraries called Purchase Orders and General Documents. Then you create a workflow and configure the Conditional Start Rule to determine if the workflow starts. In this case, the workflow should start when a document (with the word purchase order in the Name field) is added to the General Document library.

Setup Steps

The following steps set up the scenario from start to finish. If you want to skip the setup steps and view the topic step, go to Create a workflow and configure the Conditional Start Rule.

  1. Create a SharePoint library called Purchase Orders. You use this library to add all purchase order-related documents.
    1. In SharePoint, create a document library called Purchase Orders.
    2. The document library shows as below.
    3. Example of library with some purchase order documents in it.
  2. Create a SharePoint library called General Documents. You use this library to add all other documents. This includes Word, Excel, PDFs and image files.
    1. In SharePoint, create a library called General Documents.
    2. The document library shows as below.
    3. Example of library with some documents in it.

Create a workflow and configure the Conditional Start Rule

The following steps describe how to create a workflow and configure the Conditional Start Rule on the Start step. In this step, you create and configure a workflow called Document Move. In this scenario, you want the workflow to start when Purchase Orders are added to the General Documents Library. You are not worried about the other types of documents, only Purchase Orders. The workflow starts only if the condition, set in the rule, is met. In this case, the workflow starts if the Name field contains the words Purchase Order.

  1. [Create a workflow and configure the Conditional Start Rule]
    1. From the Designer click New and select Workflow.
    2. Name this workflow Document Move and click Create.
    3. Select the Start step and click the toggle to expand the Configuration Panel. You can also double-click the step to expand the panel. Select the Start with a SharePoint List option.
    4. Browse and select the General Documents library. Click OK.
    5. The Start Workflow from a List/Library page shows. Click Next. You use these references in the conditional rule later on.
    6. In the List Triggers section, select the An Item was added option and click Next. Here you specify that the workflow should start when a document is added to the General Document library. You'll add the rule later to specify the document condition.
    7. The Almost Done page shows. This page contains all changes to the library. Click Save and Finish.
    8. On the Success page click OK.
    9. The start rule is configured. Starting the workflow when an item is added to the library creates a reference in the context browser.
    10. To view the reference, open the Context Browser and expand General Documents in the References section. You use this reference to configure the condition for the start rule.
    11. To configure the condition for the start rule, select Conditionally Start and click Edit Start Rule.
    12. The Start Rule shows in the Rules Designer.
    13. In this scenario, you need to specify that if a document (containing the word purchase order in the Name field) is added to the General Documents library, the workflow should start. To do this you use the Name reference. From the Context Browser locate the Name reference and drag it into the condition.
    14. Change the operator to Contains.
    15. Type Purchase Order as the value.
    16. For the THEN option select Start. If the Name contains Purchase Order the workflow starts. For the ELSE option select Don't Start.
  2. Configure and complete the rest of the workflow. In this step you also deploy the workflow.
    1. From the Toolbox, click the Basic category and drag the Task step onto the canvas. In this step you add the task Actions. Select Yes and No. No further configuration is needed for this step.

      For more information on the Task step, see Task step.

    2. From the Task step, click and drag a line to create a Placeholder step. Click on this placeholder to create the Decision step.

      For more information on the Decision step, see Decision step.

    3. From the Toolbox, click the SharePoint category then the Document category and drag the Move Document step onto the canvas. Connect the step to the Yes task action. You use the Move Document step to specify what happens to the document. In this case, it is moved from the General Document library to the Purchase Order library. Configure the step as shown below.

      For more information on the Move Document step see Move Document step.

    4. From the Toolbox, click the Logic category and drag the End step onto the canvas. Connect the step to the No task action. Drag another End step and connect this one to the Move Document step.

      For more information on the End step, see End step.

    5. The final thing to do is to deploy your workflow. From the File menu select Deploy.

      For more information on deploying a workflow, see Deploy a Workflow.

  3. Test the solution. In this step you add a document to the General Documents library. The Conditional Start Rule evaluates the name of the document. If the name contains Purchase Order the workflow starts. If the name does not contain Purchase Order, the workflow does not start.
    1. For the first test, add a document called Purchase Order 003 to the General Documents library. Click new document.
    2. Click Choose File, browse to the document and click OK.
    3. The Purchase Order 003 document is added to the General Documents library.
    4. The conditional start rule evaluates the name of the document and because it contains the words Purchase Order the condition is met and the workflow starts. From Management, locate the Document Move workflow and select the Instances tab. Notice that workflow has started.
    5. In this scenario a task is sent to a recipient. The recipient selects the Yes action and the Purchase Order 003 document is moved from the General Documents library to the Purchase Orders library.
    6. For the second test, add a document called Invoice 003 to the General Documents library. Click new document.
    7. Click Choose File, browse to the document and click OK.
    8. The Invoice 003 document is added to the General Documents library.
    9. The conditional start rule evaluates the name of the document and, because it does not contain the words Purchase Order, the condition is not met and the workflow does not start. From Management, locate the Document Move workflow and select the Instances tab. Notice that workflow is not started.
Review

The Conditional Start Rule is logic that evaluates your data outside of the workflow and according to the outcome either starts the workflow or not. For more information see Conditional Stat Rule.