Skip to main content

Hi,


In my requirement, I have a datafield 'A'. When I Create/ Start process instance this datafield 'A' value can be null. In my workflow at later stages I need its value.


How to update its value using K2 API?


Also How to design the workflow such a way that, the workflow waits till this datafield 'A' is updated?


 


Thanks in advance


Bhavya

Add a server code event where you want the datafield updated and add some code like this:




K2.ProcessInstance.DataFields[



"PricingDone"].Value = true;




When you say the workflow should wait until the datafield 'A' is updated, do you mean that you want it to not move to a certain activity until this datafield is updated? In that case, use the preceding rule for the activity where you want the workflow to wait.


Beth


Search the developer documentation or k2underground site for references to the OpenProcessInstance method.  This allows somebody with process Admin rights to modify the data in the process.


Hi,


Thanks for the reply. Basically I'm using client events, its not working. In K2 API I use following code


processInstance=connection.OpenProcessInstance(processId);   processInstance.DataFileldse"A"].Value = "some value";   processInstance.Update();


 This code works only when the process has gone through a client event because, when I try to open processInstance before it has gone through a client event an exception is thrown.


 


 


In most cases, we normally use the OpenProcessInstance method to fix data that is incorrect.


From what you are saying, it seems that you are trying to update the data while the process is executing?


I think what I am not clear is:



  1. Why you are not inputting the data when you start the process instance.
  2. Why you can't set the data value with a server event at the start.

If the value not available at that the time of creation, maybe a start rule to delay the process execution?


To add to Johnny's post, if you need to wait for some kind of an event, you typically cannot set a rule (preceding, succeeding, line, etc.) and expect the process to automatically continue. So even if your datafield is updated, you could possibly still have a synchronization problem.


Easiest way around this I'd say would be to use an Asynchronous server event. This will wait for an update from an external system, allow you to update fields and then continue. The Help file and forum should have examples on this.


Reply