How to update a process instance data field in Sever event code

  • 6 December 2011
  • 2 replies
  • 5 views

Badge +1

Hi,


I have a process with multiple data fields that I would like to set through code running as a server event. basically i a m doing something like like:



K2.ProcessInstance.DataFields[



 



"ProcessStatus"].Value = "CREATE_SUBVENDS";



Howeveri don't seem to see where / how to have this value saved to the data field.


the process finishes without any problems but the data field has not been updated and i can't seem to see a Save or Update method....


I'm sure it is going to be something really simple but right now i have not idea....


Thanks.



 


 


 


2 replies

Badge +10

Hi Duncan


Your code looks correct for updating a process datafield in a server event.  There is no Save or Update method when run inside the process itself. 


So at this point I would typically start looking more closely at the process overview report and make sure the process the activity is being executed and that the process datafield isn't being overwritten by another event. 


Sometimes I find it helps to build a simple test process and only have the server event code in the test process to ensure everything is working correctly with your custom code.


Also note that you can use the Data event to populate a datafields without having to write code in a server event.

Badge +1

Hi Tim,


Thanks for the response... i am very certain the server event is executing (just looking at the view flow indicates this), in this instance i am using a server event because i am running a process which is querying and updating 2 other databases and i then need to update the data fields dependant on the results of those database queries and updates....


For the purposes of testing and eliminating uncertainties i will for now simplify the event code and do nothing other than set the datafields with test values to at least see if the fields are indeed updated on completion of the event.


Thanks for the help hopefully i come right.


Duncan.

Reply