Wait For Any Change on the Current List Item in SharePoint 2013 Designer Workflow

I have been trying to simulate the SharePoint 2010 Publishing approval workflow, but using a SharePoint 2013 workflow. One of the features of the SharePoint 2010 Publishing Approval Workflow is that if the item changes after an approval workflow has been started, the workflow will cancel all the approvals.

I have found two different methods to accomplish this. One is a global way that could be used for any list item, while the other specific to lists with approvals enabled.

The first method I will explain is the global way that could be used for any item in any list. Both utilize a parallel block.

Global Method

  1. Create a Boolean variable called IsApprovalCancelled and another one called IsCurrentItemChanged
    IsApprovalCancelled
  2. Create a Parallel Block
  3. Right click on the Parallel Block and access the advanced properties. Set the CompletionCondition to the IsApprovalCancelled variable
    parallel_completion_block
  4. Add two steps under the Parallel Block. One for the Item Changed, and the other for the Approval.
  5. In the Item Changed step create the following:
    1. Set the IsCurrentItemChanged to No
    2. Create a while loop where IsCurrentItemChanged equals No
    3. Add a “Wait for Event: When an item is Changed” and output the GUID to a GUID variable called ItemChanged
    4. Check if the Current Item GUID is equal to the ItemChanged
    5. Within the If statement set the IsCurrentItemChanged and the IsApprovalCancelled variables to Yes
  6. In the Approval step add any approval tasks that you would like.

Anytime an item is changed, the workflow will check to see if it’s item had changed, and if so the parallel block will end, cancelling any pending approval tasks.

Here is what Item Changed step should look like:

global_method_item_changed

Approval Enabled List Method

  1. Create a Boolean variable called IsApprovalCancelled
    IsApprovalCancelled
  2. Set the Current Item Approval Status to Pending
  3. Create a Parallel Block
  4. Right click on the Parallel Block and access the advanced properties. Set the CompletionCondition to the IsApprovalCancelled variable
  5. Add two steps under the Parallel Block. One for the Item Changed, and the other for the Approval.
  6. In the Item Changed step create the following:
    1. Add a “Wait for Approval Status to equal 3;#Draft”
    2. Set the IsApprovalCancelled variable to Yes

The key to the approval enabled list method is the built in functionality where a anytime an item is changed it will set its Approval Status back to Draft. In step 2 we set the Approval Status to Pending. Now anytime a change is made to the item, the Approval Status will automatically be set back to Draft, in which will trigger the “Wait for Approval Status to equal Draft”.

Here is an example of what the Item Changed step should look like. I kept the IsCurrentItemChanged variable in my example below, because of added logic I wanted, however it is not necessary.

approval_method_item_changed

 

Leave a Reply

Your email address will not be published. Required fields are marked *