Get all processes at an activity


Badge +1

Hi


I have an activity with one server event. In the server event the process is set to be asynchronous by setting K2.Synchronous = false. All the processes will then sort of "stack up" here as each new process gets to the server item in this activity and is made asynchronous.


Now what I want to achieve is to from a web app after a user clicked a button; i want to start all these "stacked up" processes in my code behind.


So is there a way to get all the processes that are at a certain activity; and then sort of loop through all the processes at this activity and start each one of them from the code behind ?


Regards


3 replies

Badge +8

Johann,


 


If you must use a server event, you will have to store the serial number of the event somewhere, say in a table in SQL.


Your Form will then simply open the table and go through each row which will have the serial number for the event. With the Workflow.Client API, you can call connection.OpenServerItem(serialNumber); to get a handle on a ServerItem object and then call ServerItem.Finish(); to compete the event. You will have to set a flag somewhere or delete the row out of the table once you finished the event so you don’t pick it up again.


 


Another approach if you want K2 to do the heavy lifting for you is to use a client event instead of a server event. The user which will use the page to view all the ‘Stacked up Items’ will everything in their K2 worklist. You can then once again use the Workflow.Client API and call connection.OpenWorklist to get a collection of WorkListitem objects which you can enumerate and call the WorkListitem.Action[“Complete”].Execute(), where “Complete” is the Action defined in the Client Event.


 


For that matter, you don’t even have to create a page, the user can do all this straight from the Workspace and if you configure the client event to Finish without having to open, they can even just check the checkboxes to finish it, but you probably want to display some custom information to the user before he ticks it off.


 


Have a look at the K2 Help Documentation, all the API’s are documented in there.


 


HTH


 

Badge +1

Hi


Thanks for the reply. I will try out the first option.


The only control one the web page will be a check box to indicate if a specific service is online or offline. If it's offline the processes must "queue" up in the activity and wait. If the user later then indicates that the service is online, all these processes must start again.


 Thanks

Badge +11
Just to expand on Smidde's idea.  For the SQL table I would probably use a SmartBox SmartObject.  After I had completed the server event I would delete that row from the SmartBox.  The reason I would probably do this with a SmartObject is I could probably do the whole thing without code or with very little code. 

Reply