Sharepoint Workflow - Wait until field change is triggered when another workflow changes status

I am trying to create a workflow in Sharepoint Designer. The workflow must wait for the Out-Of-The-Box approval workflow to complete. This is done by starting my workflow with item creation and assignment to the activity wait

:

Wait for the field in the current element to change:
Wait until InternalApproval equals 16

Problem: The rule is correct, but the event does not fire if nothing is done on the element. Usually every edit triggers a validation of the workflow, but my tests show that the workflow approval does not trigger this event on the item .

Is there an easy way to get around this problem? At least I'm talking about lively animation, but how (there is wait 5 minutes

activity, but no goto

)? Is there a way I can download that might be waiting for another workflow to finish or is busy until a condition is met?
Another way to solve my problem, if the InternalApproval workflow changed the field, but I can't reach it ...

+2


source to share


4 answers


I ended up writing a custom workflow that waits until a change is made and resumes the workflow. This action can be used in two ways: in the main workflow, or in a second workflow, where it waits for a change without starting, and performs a triggered change (so the main workflow resumes).
The writing was very funny - I used Reflector to copy some code from the OOTB activity (normal Wait For Field Change) and copied its xml activity. This works very well after some trying, providing a list of fields, operators and values.

Custom Sharepoint Workflow Activity - I'm blogging this



Condition checking is also pretty easy using the class Helper

. 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;
}

      

+1


source


This is expected behavior. An approval workflow that is connected to undo itself when changes are made to an item would otherwise be useless. At the API level, SharePoint disables promotion events when it needs to update the item it is running on.



-Oisin

+1


source


The article How to wait for changes in any list, wait for several fields to change the current item , for another wait for changes in the field in the current item (link below).

This article explains how to set up a workflow that uses standard workflow activities (OOB) and is developed using SharePoint Designer. Instead of using the Pending Field Changes in Current Item action, workflow components that complete after the pending completes are added to a separate On workflow that uses standard conditions in the first step to determine if it can continue. If the conditions are not met for a field in the current item, the workflow will stop. If another workflow instance is running, new instances will also terminate by setting the "Workflow_running" field to yes while the instance is running.

Using this method gives you more control while waiting for certain criteria to be met. This includes the ability to wait for a field in another list item to update or wait for multiple fields in the current item.

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

+1


source


When using one workflow for approval and another workflow for updating a field, you can use Pending Field Change in Current Item to update the field on approval (either Approved Code 16 or Rejected Code 17, Code 2) here is an example:

Wait for MomoApproval to be 16 and then set Notification to Final

This code will not fire when permission is obtained because SharePoint is modifying a field associated with a workflow; this field is not part of the list schema. Therefore, changing the status of a workflow does not trigger an item change event. Without an item change event, the second workflow will remain dormant and the Pending Field Changes in Current Item action will be useless. To work around this SharePoint 2010 approval workflow behavior, follow these steps:

  • SharePoint 2010 Open Designer
  • Go to the site you are working on.
  • Click on Workflows
  • Right click on the approval workflow
  • Click copy and change
  • Go to the appropriate list
  • Click Link an Existing Workflow
  • Now within this workflow, click Edit Workflow, select Approve Workflow Task
  • Click change individual task behavior
  • Go to full section and add this action "set Title to Current Item: Title"

This will change the title field in the list schema, which will trigger an item change event, but the title value will remain unchanged, this action will not affect the content of the list data. This is a simple workaround that works great and will cost less compared to other solutions like creating activity, looping, or pausing and restarting workflows.

Once created, the workflow can be imported into visual studio 2010 and be part of the solution, refer to this link: http://msdn.microsoft.com/en-us/library/ee231580.aspx p>

Enjoy workflow updates

Note. The workflow that updates the field must be run when there is an item change in the list.

Mohamed Hashem

0


source







All Articles