Sharepoint Workflow - Wait for field change not firing when another workflow changes status

30,226

Solution 1

I ended up writing a custom workflow activity that waits until a change is made, and resumes the workflow. This activity can be used in two ways - on the main workflow, or on a second workflow, where it waits for a non-triggering change, and makes a triggering change (so the main workflow resumes).
Writing it was big fun - I used Reflector to copy some code from an OOTB activity (the normal Wait For Field Change), and copied its action xml. This works very well after some tries, giving a list of fields, operators and values.

Custom Sharepoint Workflow Activity - I'm blogging this

Checking the condition is also quite simple, using the Helper class. All properties and their binding were copied using Reflector:

public void CheckStopCondition(object sender, ConditionalEventArgs e)
{
    bool checkAgainLater = Helper.TestListItem(Context, ListId, ListItem, 
                                               FieldName, Operator, Value);
    e.Result = checkAgainLater;
}

Solution 2

This is expected behaviour. An approval workflow that is wired to cancel itself upon changes to the item would otherwise be useless. At the API level, SharePoint is disabling events from being raised when it needs to update the item upon which it is running.

-Oisin

Solution 3

The article How to wait for a change in any list, wait for multiple field changes the current item for a different take on waiting for field changes in the current item (link below).

The article explains how to configure a workflow which uses Standard (OOB) workflow actions and is developed using SharePoint Designer. Instead of using the "Wait for field change in the current item" action, the components of the workflow which are completed after waiting is finished are added to a separate "On Change" workflow, which uses standard conditions in the first step to determine if it can continue. If the conditions are not met for the field in the current item, the workflow will stop. If another instance of the workflow is running, new instances will also stop by setting a "Workflow_running" field to yes while an instance is running.

Using this technique gives you more control when waiting for specific criteria to be met. This includes being able to wait until a field in another list item is updated, or waiting for multiple fields in the current item.

See How to wait for a change in any list, wait for multiple field changes the current item (SharePoint Workflow) for more details.

Share:
30,226
Kobi
Author by

Kobi

My blog: ⚫ Regex for solving mazes ⚫ Why was I a fox? ⚫ Take photo, hear haiku ⚫ Recreational regex Answers: Regex + HTML ⚫ PCRE Grammar to .Net I’m 38 and live in Tokyo. Interested in programming, reading, privacy. My dream is making the world better using regular expressions. Mortal enemy of Sancho Panza. 🇮🇱➡️🇯🇵 Feel free to contact me: gmail: kobikobi twitter GitHub

Updated on July 11, 2022

Comments

  • Kobi
    Kobi almost 2 years

    I'm trying to create a workflow on the Sharepoint Designer. The workflow should wait until an Out-Of-The-Box approval workflow is complete. This is done by starting my workflow with the item's creation, and usign the wait activity:

    Wait for field change in current item:
    Wait for InternalApproval to equal 16

    The problem: the rule is correct, but the event doesn't fire unless an edit is made on the item. Normally, every edit triggers the workflow check, but my tests show approving a workflow doesn't trigger this event on the item.

    Is there an easy way around this issue? I though about implementing a busy wait, but how (there's a wait 5 minutes activity, but no goto)? Is there an activity I can download that can wait for another workflow to complete, or busy wait until a condition is met?
    Another way to solve my problem is if the InternalApproval workflow changed a field, but I cannot achieve that either...