Skip to main content
Hi All,

Can any one help me out with following

1) I need to invoke K2workflow with an submit event in winform ( c#)
2) How can I invoke winform application from k2.net workflow from sharepoint portal
Hi Ajay,

Invoking a workflow from a windows forms application is the same as invoking a workflow from an asp.net web application. All you need to do is use the K2ROM to connect to the K2 server and then start the process. There is some sample code of how to do this in the help files that are installed with K2. There are also some tutorials available on the portal site that go through some sample scenarios: http://portal.k2workflow.com/downloads/tutorial.aspx

Here is the basic code for starting a process instance:

public void StartNewProcess(string K2Server)
{
SourceCode.K2ROM.Connection oK2Connection = new SourceCode.K2ROM.Connection();
SourceCode.K2ROM.ProcessInstance oNewProcessInstance;
oK2Connection.Open(K2Server);
//Create New Process Instance
oNewProcessInstance = oK2Connection.CreateProcessInstance(strProcess);
//Populate DataFields
oNewProcessInstance.DataFields["Name"].Value = "Danie";
oNewProcessInstance.DataFields["Surname"].Value = "Botha";
oNewProcessInstance.DataFields["EMail"].Value = "danie@email.com";
//PlanStart new Process Instance
oK2Connection.StartProcessInstance(oNewProcessInstance, false);
//Close the Connection
oK2Connection.Close();

}

For the second question are you trying to figure out how to start a windows form application from SharePoint? If so this is not something that I have done or know how to do but I imagine there is probably a way to do it. If anybody else knows how this could be done let us know?

-Eric
Thanks eric for your reply.

You nean to say we ship K2ROM.dll with every client. In case we have got some limitations in that, are there any possibility that we can consume some webservice through Winform and invoke K2server with K2ROM.
You can wrap the sample code above in a webservice and pass all data needed in XML.
i am facing issues in accessing K2ROM apis.
i have tried making a dll where K2ROM is added as reference and the apis are used for creating a process instance.
it didnt work.
then i tried doind it with the web service.
that gave the following error.
Request for the permission of type 'System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.CodeAccessPermission.Demand()
at System.Net.HttpWebRequest..ctor(Uri uri, ServicePoint servicePoint)
at System.Net.HttpRequestCreator.Create(Uri Uri)
at System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase)
at System.Net.WebRequest.Create(Uri requestUri)
at System.Web.Services.Protocols.WebClientProtocol.GetWebRequest(Uri uri)
at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebRequest(Uri uri)
at System.Web.Services.Protocols.SoapHttpClientProtocol.GetWebRequest(Uri uri)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at COT.Service.CreateProcess()
at COT_UI.CTRL44_10_OnClick(DocActionEvent e)
at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)

can somebody help me with this?
Maybe you need the upcoming K2 SP4 to work with VS2005.

Reply