Question

Unable to receive data from child process to the parent process while using IPC in K2 blackpearl.


Hi,


I've a K2 process using IPC events that calls a child process.


Process1 is the parent process and Proc1 is the child process.


From a client application the following code is called.


con = new SourceCode.Workflow.Client.Connection();
con.Open("K2Server");
SourceCode.Workflow.Client.ProcessInstance procInst = con.CreateProcessInstance(@"K2_IPCProcess1");
procInst.DataFields["ProcessToCall"].Value = @"K2_IPCProc1";
con.StartProcessInstance(procInst, true);//Calling synchronously
System.Threading.Thread.Sleep(1000);
string processInstanceID = procInst.ID.ToString();[Is able to return the ProcessInstanceID]
bool isStarted = Convert.ToBoolean(procInst.DataFields["ChildProcessStarted"].Value);
Response.Write("The process instance id of the process is:" + processInstanceID+"<BR>");


Response.Write("Is child process started:" + isStarted.ToString());[The value is always false]


Explanation:


While using the IPC wizard:


In the Process, Folio and Type of Call wizard.


Specify the process to be called.
Process: ProcessToCall(is a field that says, which process to invoke when the parent process is started. This is passed by the custom code above.)
Select how to call the process.
Synchronous(wait for the child process to complete)



In the Map a Process Field wizard, I've selected the Data Direction as "Receive data from child process"



Parent Process (this process)
Field Name: ChildProcessStarted (is a boolean value initially set to false)



Child Process
Field Name: ProcessStarted (this is a field in the child process which updates data field ProcessStarted to true)



So, the value of ProcessStarted should be assigned to ChildProcessStarted field when the Parent process is run through code.
But, it never updates the ChildProcessStarted field to true though the value of ProcessStarted is set to true.


Can anyone provide their comments.


19 replies

Userlevel 4
Badge +3

Have you looked in the the K2 Process Overview report to ensure that your parent and child process are doing what you expect them to.  I would recommend just testing it without your code and looking at the process datafields in the reports to make sure there isn't some configuration error.  Also take note of the times when the child process is starting and completing.  In the most recent version of K2 the child process may not start immediately and may be delayed by about 1 minute.  Same thing for returning to the parent. 


Hope that helps.


Tim

Hi Tim,


As explained by you, I'm able to see the values set in the Process Overview reports but this is not getting assigned to the field in the client application that calls the K2.


Also, K2_IPC is my solution that contains Process1 & Proc1 as 2 K2 processes.


Process1 is the parent process and Proc1 is the child process.


When deployed, I'm able to see Process1 & Proc1 process and able to assign rights to them separately


However, in Process Overview reports, I'm only able to see the datafields assigned to Process1 but I'm not able to find any information related to Proc1. Any reason why?


Also, please let me know, how can I make the client application and K2 process in sync, such that whenever the child process is started, it should assign the parent field and this should reflect in the client application.


Appreciate your inputs.

Userlevel 4
Badge +3

I suspect Proc1 simply never started. 


Check what authentication option you choose in the IPC event to start Proc1.  Then check what the start permissions are on Proc1.  My guess is that Proc1 is set to start as the originator and the originator has permissions to start Process1 but not Proc1.


Check the event logs as well if my guess is incorrect as it should provide clues to the problem.

Hi Tim,


Integrated Windows Authentication has been used in IPC.


If Proc1 is not called, then how did the boolean value of  "True" was returned to the Parent process.


The boolean value is set in the child process.


But, I don't see any instance of Child process in Process Overview reports or in the Process Instances of the process itself i.e., Proc1 --> Instances.


Nothing is logged in the event viewer as well.


Also, sufficient permissions(Start rights) were there on both the processes i.e., Process1 & Proc1.


Appreciate your comments.

Userlevel 4
Badge +3

Does your account have view permissions on the child process?  That's the only reason I can think of for it not showing in the process overview report assuming that it has been initiated.  Maybe you can post a screenshot of the process overview for Process1 and the drill down into the events of the activity that contains the IPC event.  Also take a look at the Start and Finish times of the IPC event.  What's the difference between the 2?

Hi Tim,


Thanks.


You were right. The View rights on the process was missing. Now, I'm able to view the instances of Proc1 as well.


How can I make the client application and K2 process in sync, such that whenever the child process is started, it should assign value "true" to the parent boolean field and this should reflect in the client application.


Only when I get the update from my parent process about the boolean value("true" when the child process is started), I'm allowed to go/move forward. Please let me know of how can I achieve this.


The intention is that I should be able to decide from within the client application whether the parent and the child process have started successfully. The only field that I can check is the boolean value in the parent field.


You have given all the right inputs. Hope you provide your inputs on this situation as well.


Appreciate your reply.

Hi Tim,


Appreciate your inputs.

Userlevel 4
Badge +3

I think your original idea would probably work except that you might not be waiting long enough to get the corect response or should keep checking..  You should be able to see this in the process overview report by looking at the end date of the IPC event.  Otherwise one of the following approaches should accomplish the same thing.


1.  Pass a known value to the child and then query the child to see if its started.  Possibly using the out of the box Process data Smartobject filtering on the known value.  Polling scenario


2.  Have the child call a webservice. 


3.  Use a async server event which calls your child app and then its your child app which basically finsihes the the async serve event which allows the child to continue

Hi Tim,


Could you please elaborate on your inputs. Is it possible to give a very small example?


Regards,


Phanibabu Kandala

Hi Tim,


Could you please give more inputs on this?


Appreciate your comments at the earliest.


Regards,


Phanibabu Kandala

Hi all,


Any pointers to my scenario?


Regards,


Phanibabu Kandala

Hi Tim,


Could you please elaborate on your inputs. Is it possible to give a very small example?


Regards,


Phanibabu Kandala

Userlevel 4
Badge +3

Hi


I've been away on holidays and have just recently returned. 


At this point since my suggestions haven't helped I don't think I understand exactly what you're running into. 


Please post your process even if its simplified only to show the problem.  Also include some screenshots of the process reports of the parent and the child and the process data at the different steps.  With that information I think I can help you.

Hi Tim,


I'm able to start the IPC process synchronously using K2 APIs and it works fine.


Within the IPC event, I've declared a field and tried with both the Data Direction options like


 "Send data to child process and receive data upon completion" and "receive data from child process"


The problem is that the child process is able to start successfully but it is not updating the parent process saying it has started. Is this an internal feature of IPC that happens automatically (child process updates parent process data fields) or do we have to write any custom code to update this.


I've also tried something like this in my child process to update the parent process data field.


SourceCode.Workflow.Client.Connection con = null;
           
try
           
{
           
    con = new SourceCode.Workflow.Client.Connection();
    con.Open("K2Server");
           
    parentProcessInstID = Convert.ToInt32(K2.ProcessInstance.DataFields["ParentProcInstID"].Value);//I'm passing the parent process instance id to the child process.
            
    SourceCode.Workflow.Client.ProcessInstance procK2 = con.OpenProcessInstance(parentProcessInstID);
    procK2.DataFields["IsChildStarted"].Value = true;
    procK2.Update();////The control gets stuck up here and doesn't give any information.
   }
catch (Exception ex)
{


}


On the UI, I check for the parent process data field which is say suppose a boolean field to take a decision. The data field always returns false even though the child process has started successfully. I want this to happen dynamically.



But, in no way child process is updating the parent process data field.



If the child process is started successfully, then the parent process data field should be updated accordingly.
Child Process Started successfully  -- Parent process data field should indicate true
Child Process failed  -- Parent process data field should indicate false


Tried the other way as well:
I've also tried using the Process Overview SmartObject to see what value is set for the data field that indicates whether the child process has started successfully or not.
But the problem is that when I tried
SourceCode.SmartObjects.Client.SmartObject smartObject = serverName.GetSmartObject(strSmartObjectName);//the name of the smart object
It throws an error stating that "The SmartObject [Process Overivew] could not be found."


I tried several searches on K2 UnderGround but have found no inputs.


Appreciate your inputs.


Regards,


Phanibabu Kandala

Userlevel 4
Badge +3

Okay I believe I see what the issue is.  You want to see when the child has started.  The issue with the IPC fields is that the child will not pass data back to the parent until the child is complete.  That is by design.


I recreated a sample to demonstrate the problem and the solution I came up with is somewhat similar to yours in that through code I'm reading an out of the box K2 "process data" reporting smartobject to see if the child has started filtering on the process name and the process id.  I've included the sample below.  The problem in your code is that you're using the SmartObject display name and not the actual name which would be Process_Overview with the underscore..


Here is my sample processes and the sample code to read the smartobject. 


[View:http://www.k2underground.com/cfs-file.ashx/__key/CommunityServer.Components.UserFiles/00.00.00.23.87/Get-Data-From-child.zip]


 

Hi I get the dataFields(Email) for the workflow from database-SmartObject--If the email address changes in the middle of the workflow.DataBase is updated.How to update the workflow to take new email from database.


thanks


sujatha

I actually resolved the problem of SmartObject. I have given the smartobject name as "Process Overview" which should have been "Process_Overview."



Now, I'm able to call all the SmartObjects.


However, there is a concern in the IPC event.



In the wizard for IPC event, it asks us to enter values for the "Edit Design Time Values."
Suppose, I specify the details of "Child1" process and deploy, it is only able to call Child1 and not able to call Child2.



Suppose, I specify the details of "Child2" process and deploy, it is only able to call Child2 and not able to call Child1.



It shoots the error as "28025 Failed to Start IPC"



Hope you could provide some inputs on this. I think we're approaching at a solution.


Thanks & regards,
Phanibabu Kandala

Hi Tim,


Thanks for the update.


But unfortunately, I don't have the latest version of K2 installed and hence not able to open your solution.


Could you give your inputs on the IPC event error.?


Thanks & regards,


Phanibabu Kandala

Userlevel 4
Badge +3

From your description it sounds like in the same IPC event you'd like to call either Child1 or Child2 or some ChildX.  I've designed a similar process in the past successfully.  The only gotcha that I can remember is that all the data fields that you're transferring to the Child or back to the parent would need to be in each Child process (even if you don't use the values) otherwise an error would occur.  You can then use a process datafield variable for the child process name that you want to call.


I also found a blog post about possible reasons to receive this error which also includes missing datafields and incorrect datafield types:  http://www.makingflowwork.com/2011/06/28025-failed-to-start-ipc/


There found a KB article describing the error code and a hotfix but that was for an old version of BP 807 so it probably doesn't apply.  http://help.k2.com/en/KB000324.aspx  

Reply