Skip to main content

Hello K2 Developers,


I am working on an application where a service will be used to start a K2 process instance using the K2 API.  Surrounding this call I am also writing data to an application database, which is all done within the scope of a transaction.  I was testing if the start process function would observe the rollback, which it apparently does not.  Is anyone aware if it can be configured to observe the transaction or if anyone has attempted to create a custom wrapper that would implement this desired functionality.


Thanks in advance for your replies,


Mark

Hi Mark,


Unfortunately you will have to manage this as the StartProcess method is not transaction aware. You have 2 options:


1. use the K2 API to check the process was successfully started (specify a unique 'Folio') 


2. write to the application database from within K2.


HTH


 


Hi Conrad,


I had a follow-up question to your advice above.


With regards to suggestion 1, is it correct to say that it is not guaranteed that this check will be foolproof 100% of the time? For ex, if in my custom code, I call K2 to start a process, and in the very next line I check if that process was successfully started, it is possible that the process might still be in the state of being executed by the k2 engine and hence the status would not have changed to "Started" yet.


With regards to suggestion 2, if we write to application database from within a server event in K2, do we need to explicitly create a transaction object and enclose all db operations within it, or is it automatically done by k2's engine? I guess what I am looking for is whether custom code written in a Server Event automatically gets executed in a transaction context, without having the need to explicitly specify it.


Thanks.


Reply