Is there an out of the box activity that makes the activity wait until a SharePoint field changes to a certain value before executing the next activity, much like SharePoint Designer workflow activity of the same nature?
What I'm basically trying to do is, when I have a new SharePoint item added, I need to wait until the field Status_D = 2 for my approval to start. Now, for Status_D to equal 2, three statuses (Status_A, Status_B, Status_C) all need to be equal to 1. Status A is updated to 1 first, then Statuses B and C are updated to 1 in parallel. Status_D is changed programmatically.
Is there a way to implement this (using SharePoint Workflow Integration with a "wait until..." activity) without programmatically starting the workflow when my application changes Status_D to 2?
Would appreciate your help so much. Thanks!
There is not an out of the box event to wait for a workflow change. However, what you want to do can be accomplished using other OOTB techniques. The basic idea is we will store the Serial Number of an event in the main workflow in a document library field and then use an asynchronous server event to wait until the field is changed. A second workflow will be started every time an item in the library is changed and if Status_D = 2, it will use the stored serial number to resume the main workflow. For some background info, please check out my comments on this thread:
Add a new column (you can hide it from the user if you like) to the document library called 'SN'. In the main workflow that must wait until Status_D = 2 you add a SharePoint Document event to update the new SN colum with the SerialNumber of the current event. (Note: you can get the serial number from the Workflow Context Browser by combining the ProcessInstance ID, an underscore, and the Activity Destinatibn Instance ID). Immediately after the document event, add a server code event and set the event to asynchronous with this line of code:
K2.Synchronous = false;
This will cause this event to wait until it is acted on outside of the workflow.
Create a second workflow. For this one, use the SharePoint Events Process Wizard to cause this workflow to be started when an item is changed in the library. Assign the SN and Status_D fields to process-level fields. Create a start rule for the workflow that only returns True when the item that starts the workflow has StatusD = 2. In the first activity, create a server code event to execute code similar to the example in thread 23798. Use the SN on the document as the SerialNumber of the server event to Finish.
Make sure you give the account running the K2 service the Server Event process right on the main workflow.
I think this can be answered in this way:
Most often we are accustomed with the out-of-the-box functionalities in SharePoint to start a workflow attached with a list / library.There might be a requirement where the workflow needs to be started manually from within a programming interface i.e. a custom form which can be used for triggering workflow on specific list / library items.
An example for the above requirement is provided below using VB.Net as the programming language.
Dim list As SPList = web.Lists("ListName")
Dim lstItem As SPListItem = list.GetItemById(itemID)
'obtain an instance of SPWorkflowManager which will be used to start the workflow
Dim manager As SPWorkflowManager = site.WorkflowManager
I need a k2 event similar to SharePoint Events Wizard
i want to implement the basic wait condition in K2 that waits for a specific condition to resume execution
at a high level I'd do the following.
I’d create a custom CRM entity
that stores a reference to the primary entity either as a look up or just it’s
guid, the value of the lookup you are waiting for, the process instance id of
the K2 process and the serial number of the activity.
In the activity of the K2
process where you wish to wait I’d write an entry to the custom entity with the
relevant details and in the next event establish an asynchronous server event (as David describes above)
I’d then write a custom CRM
plugin that fires on the pre or post update of the primary entity. The plugin
would check if the custom entity had any records relating to the primary
entity and if it did it would retrieve that record. If the primary entity’s
lookup field matched the value in the custom entity then get the serial number
and use the K2 API to complete the asynchronous server event.