Skip to main content
I need to be able to update a separate database with data whenever it changes. K2.NET best practices indicates that the data should be sent to K2 and then updated into the database from there.

Our custom application requires (because BA's say so) that Managers can edit and change data at anytime. To do this the worklistitem.update method is being utilized. This method will not trigger any events in K2.NET to fire so I cannot respond to the update to write to the database.

So ... the idea is to use a helper process that uses the K2ROM to update the activity id (serial number) that is passed in. It is recommended to not access a process using the K2ROm while IN that process due to locks but what about accessing it from a separate process?
I would suppose that at some time your process would need to be approved and the data would be updated to your database.

The worklistitem.update method is usually used for saving process data without completing the work item. Theoretically, the updated data should be updated into your database once the approval work item is completed.

However, if you are looking for instant data changes. Perhaps making the update function as a separate "Change/Edit data" process might make more sense. Note that this is one possible option off the top of my head. As we say, K2 is pretty flexible and there are many ways to skin the cat.
I am only aware that you can not use K2ROM in K2Studio.

"It is recommended to not access a process using the K2ROm while IN that process due to locks"

It seem your external process already calls K2ROM directly, you would probably want to wrap the data updates in a transaction with your custom database first, then K2ROM update. Once K2ROM update is successful, commit, if error you can rollback your custom database update.
icon-quote.gifPeter Yao:
I am only aware that you can not use K2ROM in K2Studio.

"It is recommended to not access a process using the K2ROm while IN that process due to locks"

It seem your external process already calls K2ROM directly, you would probably want to wrap the data updates in a transaction with your custom database first, then K2ROM update. Once K2ROM update is successful, commit, if error you can rollback your custom database update.


Never call K2ROM to operate on the current process instance from an event within the current process
The K2ROM should never be utilized within a server event to operate upon the current process instance. This includes directly accessing the K2ROM or accessing a business object/external assembly that contains the K2ROM.

Attempting to use the K2ROM to operate on the current process instance from within the execution of the current process instance can result in inconsistent behavior and/or crashing of the K2.net Server service. This because is the K2.net server locks the processes that is currently executing and cannot connect back to itself with the external K2ROM as described.

However, there are situations where this sort of functionality is required. For instance there may be a process level escalation that has a server event waiting to be completed. The only way to do this is by using the K2ROM to finish the event. In this case, the solution is to create a very simple K2.net workflow with one activity. The K2.net process should contain some datafields to be used by K2ROM (Serial Number, Server etc) and use the K2ROM here to connect to a workflow process and finish the event. Call this sub process from the main process where you need to use the K2ROM in the process and this will work as it connects to the sub process releasing the lock on the main process allowing the sub process to use the K2ROM to connect back.

If I am interpreting that correctly then they are indicating the type of scenario that I am suggesting but the semantics of it are not mentioned.

Reply