Hi K2 Guru's,
I need to update the Folio field of a process instance to include the ID of the process instance. For various reasons I don't want to do this in the workflow itself. Currently I take the following steps:
1. Create a process instance using K2ROM API. At this point the ID of the process instance is unknown.
2. Start the process instance (with sync set to false otherwise I run into all sorts of sync problems that goes beyond this discussion).
3. Now I have the process instance ID so using the same ProcessInstance object, I set the folio and then call Update on the process instance object.
I have a few problems (known and unknown) with this. If the process is in a running or active state at this point, the Update call seems to work fine. I'm worried what else could be updated when making the Update call, i.e. the process sets a datafield thats not currently reflected in my process instance and I override it when calling Update? What does Update on the process instance do exactly?
Secondly, if the process instance has completed by the time I call Update, I get an exception... can I check for certain process instance states before calling update? Again, the status I might see on the object is probably not the exact current state of the process?
Am I doing this all wrong, and if so, how can I get the ID of a process instance BEFORE I start it to avoid the issue above?
Thanks,
Gabriel