Skip to main content

I have a scenario in which I want to create n number of child processes that run in parallel.  I would like to use an IPC event to handle this.  I have custom destination rule code that creates the destinations for the activity that has the IPC event.  This will successfully create on child process for each destination I add. 


 What I don't know how to do is pass specific data to each child event. 


Example:  My custom destination rule code adds 5 destinations (users) that I want to create a child process for. The 5 child processes are created.  However, I would like to have information about of each destination (i.e. hometown, age) passed into the respective child process.  So child process one has datafields that read Tom, Texas, 26, child process two has datafields that read Mike, Mississippi, 24, and so on.


I I have this data at the time my custom destination rule code runs.  Can I achieve this?

Hi bdoc7k2,


One approach is to create a series of ActivityLevel datafields (Hometown, State, Age etc) and within your activity your first event is a DefaultServer.  Within the default server event check to see which destination your currently on and set these fields appropriately.  Your second event can be your IPC event which maps these Activity datafields into the sub process.  This will allow you to; for each destination you have map the appropriate datadfields into the sub process.


If you find this approach flawd let me know and we can think of an alternative.


 -mike


Using no destinations and simply recursively going to the same activity by tracking my data to be passed into each child process and a counter, as described in this post


http://k2underground.com/forums/ShowThread.aspx?PostID=8157


almost works perfectly. 


The only problem is it always stops after two recursive cycles.  I have a regular server event (the one that updates my counter) followed by an IPC event.  The IPC event says it completes in the workspace report, but only the first two actually create child processes. 


 Any ideas?


Hmm,


So are you looping back to the same activity using a counter and a line rule?  If so, it sounds like their could be a problem with your incrementing and counter tracking.  You should haven't have any problems looping n number of times.  I assume your IPCEvent is in wizard mode and but have some code in a server event.  As basic as it is could you post your server event counter code and explain what rules you also have (line & slot destination and succedding)?


PS: Your previous post lead me to beleive you were creating all our destinations rather than looping back to the same activity numerous times.  Does it sounds like I have miss understood something?


-mike


You didn't miss understand - I started with multiple destinations, but then I found the post on recursively looping.


It is now working correctly!!!  Starting a new instance of IE seemed to get it to create all the child processes I expected.  Weird - but I think we're good.  Thanks for the ideas.


In the interest of sharing, here's what we've got going now:


An Activity with a Default Server Event and an IPC Event (wizard based).  And there is a Line that loops from the Activity back to itself.


My Default Server test code:


 strings] states = new strings]{"OH","IL","WI","GA"}; // in reality this would come from xml field
 K2.Synchronous = true;
 int stateIndex = (int)K2.ProcessInstance.DataFieldsa"CurrentStateIndex"].Value;
 K2.ProcessInstance.DataFieldsD"CurrentState"].Value = statesestateIndex];
 System.Diagnostics.EventLog.WriteEntry("SLM",string.Format("Current state: {0}",K2.ProcessInstance.DataFields."CurrentState"].Value.ToString()),System.Diagnostics.EventLogEntryType.Information);
 K2.ProcessInstance.DataFieldse"CurrentStateIndex"].Value = stateIndex + 1;


The line rule for the line that comes back to the activity is:


/{K2.ProcessInstance.DataFields("CurrentStateIndex").Value}] < 4


The IPC event passes CurrentState into the child process.


Excellent, well done.

Reply