Skip to main content
Hi Guys,

We've used K2ROM in an ASP.NET page to start a process and set some process level variables. We want to handle any exception that occurs on the K2 side, eg. in the server event of an activity if an excpetion occurs, is there any mechanism that the UI can "know" about this and throw an error page.
I am aware of the AddToErrorLog method, but that is not addressing the issue of how I can throw this error back to the UI.

Please suggest a way of doing so.

Regards,
Shortwire
Folks,
Any luck on this?

Regards,
Shortwire
Hey Folks,
Even if this is not possible in K2, I just need to know the best way to handle this. Can someone please help me out? This is pretty urgent as I need to submit my design to the client shortly.
Regards,
Shortwire.
Hi shortwire,

Have you tried using K2Mng to get the Errors?

I think permissions might be an issue here, because the user needs to be an administrator to view the error profile, but it is worth a try.

There are some sample code available on K2Mng in the K2.net 2003 Help document.

I don't know if this what you require but it could be helpful.

Regards,

Johan Liebenberg
Thx Johan for that. But that would mean "asynchronous handling of the error. I will explain why.
Say I have an ASP form which on pressing of submit, needs to do 2 things
1. Update some values in the database.
2. Call the K2 process to proceed with the workflow.

Now I would like to have this as a "single transaction". If the database call fails, step 2 will not be executed. This is fine by using a try catch block. But the other one, ie. if the K2 call fails, the database update should roll back. This is where the problem is. Even if I put these two in try catch, the database call happens and then when K2 fails, its going to log the error and simply "NOT THROW" any exception to .Net framework. So theere would be no exception in the UI and it would commit the changes to the database.

If I check with the K2Mgr credentials after updating of step 1, then it is not guranteed that when I am checking the exception in Error profiles, the error has actually "hit" it. As a result, the entire stuff becomes asynchronous and unreliable. Any idea how I can make the above steps 1) and 2) as a single transaction?

Regards.
Shortwire
Taking a step back, why not put the database update in the K2.net workflow, as a server event after the activity?

That way, you will get the combined transactionality for "free"; The DB update wont happen unless the page submits successfully and if the database update fails you can either deal with it as a normal K2.net error (in Service Manager) or even redirect to the previous page (so that the person has the opportunity to just submit it again later).

There is little or no advantage to performing backend functionality in the ASP.NET page over and above doing it in the workflow - but there are many disadvantages. It is the same .NET code being run in either case. Also, it is a usability issue if people must wait for back-end functionality when interacting with a system - it is the responsibility of a system to deal with data, not the responsibility of the user.

Hope that helps and makes sense!
I dont know whether this would make sense in all cases but, just another thought on this... to show K2 errors in a UI, one could write exception handling code in the process, activity or event level, that stores the exception information in a process field. So later you can retrieve that information and display it to a user and then reset that exception information as appropriate.

Reply