Returning the processinstance id of a new process.


Badge +2
Someone help please! We have 2 processes, one called the initial evaluation process and the other the CI knowledge process. We are starting the CI knowledge process from the initial evaluation process using IPC Server, we are also passing datafields and some XML fields to and from the 2 processes.

The user starts a new "initial evaluation" process and follows a couple of aspx pages before a page asks the user whether or not he/she required additional information (help from expert users, such as yourself :D ) when the user selects "yes" and submits the page, it starts the CI knowledge process and brings up a new page where the user has to select a group that the process has to be sent to.

Now the problem is that when we start the CI knowledge process we need the processinstance id to read and set various datafields inside of the process, the first couple of screens use sessions to read the processinstanceid which has been the same from the start, seeing that it has been one process that has been used the whole time. When we start the new process we cannot use the same processinstance id and need to get the processinstance id of the new process that has been started using the IPC Server.

Is this even possible?

6 replies

Badge +11
Can't you just use a Server Event within the very first (after Start) Activity of the CI knowledge process and set the datafields with the appropriate process instance id - K2 As ServerEventContext has got a K2.ProcessInstance.ID property.

Hope this helps,
Ockert
Badge +2
Hi Ockert, the problem is that we also need to read from the process datafields as we need to display information to the user.

Will it work if I set the datafields in the first process? Will it send the changed values through to the new process? I have set the direction as in/out.
Badge +11
the problem is that we also need to read from the process datafields as we need to display information to the user.
Sure, but you can read and display the process datafields to the user AFTER you've manipulated it in the first Server Event.

Will it work if I set the datafields in the first process?
Depending on whether or not the process instance id is contained within these process datafields. By the time the parent process is executing, you obviously do not know what the process instance id of the child process will be.

Will it send the changed values through to the new process?
It will send through whatever the values of the datafields are at the specific point in time when the child process is created.

Maybe I'm misunderstanding...
Can you give me an example of your datafields which is transferred between the two processes.

Regards,
Ockert
Badge +2
Hi Ockert.

If I understand correctly, there is no way of getting the processinstance id of the new process inside of our C# code?

I really hope that I'm misunderstanding what you are saying...

What needs to happen is that once the user clicks on next on a screen called IE3.aspx (initial evaluation 3) with "is additional information required" selected as "yes" the CI knowledge process needs to start and the user will be directed to K1.aspx (knowledge 1), this form needs to read and set values inside of the CI knowledge process. In order to do this we need the processinstance id.

I hope this gives a little more clarity to what needs to happen...

Maybe we're just trying to over complicate things. :?
If there is a better / easier way, please tell me as I'm still pretty new to the whole workflow development thing.
Badge +11
If you start the child process through an IPC Event, then no, there is no way to get the process instance id of the child process. However, if you start the child process synchronously through a K2ROM connection in C#, then it would be possible to retrieve the procinstid and set process level datafields through code. The problem here would be the passing of data BACK to the parent process - you'll have to extensively keep track of procinst id's. Please have a look at the following post: http://forum.k2workflow.com/viewtopic.php?t=662

Something that would bother me though, is the continuation of aspx pages for the same user across processes. Why don't you finish interaction with the one user in the parent process and then pass it over to your "expert" users in the next process - waiting for their interaction.

It sounds to me that you're in need of some design consulting. Please contact your local K2Workflow Services office and ask for some assistence.

Best regards,
Ockert
Badge +2
Thanks Ockert, after reading your replies, I made the suggestion to simplify the processes to a point where we can have 1 process handling the flow.

Reply