Fluff,
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:
http://www.k2underground.com/forums/thread/23798.aspx
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.
David
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
|
David,
I am trying to do similar scenario but using MS CRM, I am trying to resume a K2 Process Instance when a field changes on a CRM Form, can you please advise how can i resume a k2 Process Instance using Javascript or Code.
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
Mira
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.