Skip to main content
I wanted to know if there currently was a method of activating a K2 Process when something was entered into a specific table in a database.
Use insert trigger to call an external process (webservice, DLL, write a file that a Windows service picks up) that initiates the workflow.

I don't know if anyone has written .NET code within SQL Server 2005 to initiate the Workflow directly.
I have a .EXE File that does nothing but activate the process I need. I found some code to start it from a trigger, but when I do the trigger hangs. At first I thought it was an exception of some kind, but I tried it on the command line and it works just fine. Does anyone know a work around, or perhaps I could run a batch file that will call the .EXE file?
Can you post the exact code you are firing off the trigger? Any way to launch the exe asynchronous so trigger isn't waiting till exe is finished?
All of the code is pretty standard I set a variable that contains the information about the program needed to run I do not remember the exact syntax of the command I used, but it it something like

EXEC xp_cmdshell, @pathvar, no_output

I don't have access to the code at the moment, so I am not 100% sure if this is correct.
That should do the trick...

I'd like to see the code for the EXE file you're running as well. Is this a VS.NET console application? Are you setting your K2Server, project and process to be started in this application? Under which user context does this app run? Maybe the user hasn't got rights to start the process. Any error messages in K2Error.txt?

Regards,
Ockert
Apparently, if the user under which SQL Server is running has limited rights (e.g. not an administrator), you may encounter security problems executing the code in the Trigger (specifically, the xp_cmdshell stored procedure).

More information about this is available from the following site:
http://www.databasejournal.com/features/mssql/article.php/1580041

Attached sample code for the .Net sample application and the trigger.

Reply