how to open another ProcessInstance from a server event

  • 26 July 2007
  • 5 replies
  • 0 views

Badge +7

Hi all,


I would like to open an other processInstance into a server event to set some data on it.


I didn't find any known method to do that like "Connection c = new Connection(...)" and "c.OpenProcessInstance(...)" into the server event code...


 Can someone help me?


 


Thanks


5 replies

Badge +5

Hi TanguyLSY,


 When you say "open another process instance", do you want to create or launch a new process instance from a server event?  Or do you want to open a particular work item (client event) from a server event?


-mike

Badge +7

Let assume I have a process A


During my process, I've launched through a form a new process (B) and I gave it the ID of process A.


in a server event in process B, I want to open Process A to update some of its datafields.


What is important here is that process B does not come from an IPC event.

Badge +5

After you give process B the ProcessInstanceID of process A your code should look like this.


using SourceCode.K2ROM;


private void UpdateProcessAFromProcessB(int ProcessInstID)
{
      Connection cnn = new Connection();
      cnn.Open("ServerName");
      ProcessInstance pi = cnn.OpenProcessInstance(ProcessInstID);
      pi.DataFields["MyDataField"].Value = "NewValue";
      pi.Update();
}

Badge +7

Thanks but... I know how to update a datafield but if I paste your code directly in a server event, does it work?


 I mean, I'm not sure that K2ROM library is available directly in a server event code...

Badge +5

It's not, you'll want to wrap this code in a web service or assembly.  Also note that you should never open a connection back into the currently running instance.  For example if the current process that is executing is ProcInstID 100, within this process there should never be a server event that opens a connection back into this running process (100).  The server will lock most of the time.  However, in your scenario it is acceptable to open a connection from one process into another.


-mike

Reply