Item not found in this collection - Calling another workflow via workflow SmartObject


Badge +1

Hello,

 

I am getting an issue where I am trying to call a workflow via a SmartObject Event in Visual Studio 2015. Everything seems fine, I am able to put the correct workflow smartobject into the workflow and map up the inputs for the StartProcess method on the SmartObject.

 

I created the SmartObject in the child workflow by checking Create Workflow SmartObjects in the SmartObject Association setup.

 

When I then run my workflow, it errors out with the message "Item not found in this collection". I see the error message via the Management Console in K2 Workspace.

 

I can execute the SmartObject method via the Service Tester and it runs fine, no errors or anything.

 

Anyone have any ideas?

 

Thanks!


2 replies

Userlevel 1
Badge +8

This isn't a recommended approach. To call another workflow, it is best practice to use the IPC event.

 

The reason you are most likely getting this message is that the SmartObjects for workflows are paired with a specific version of the workflow, if you have made changes to the workflow in subsequent deployments the start signature (process data fields exposed) may have changed and are inconsistent with the smart object.

 

Now, you may be faced with a situation that you cannot see the process you wish to start. True, K2 looks at the immediate project to map up an IPC for that is only for DESIGN TIME. Run time settings in the IPC wizard you can type in the qualified name of any process you wish to start.

 

But How Do I Get the Design Time Values for my process?

That is simple, just add a copy of the KPRX for the process you wish to target. Or even just add a KPRX for a stubbed out process to stand in for the one you want to start just ensure that all the process data fields are properly mapped. be sure to exclude this process stub from the build as you WILL NOT deploy it. That process stub is just there so K2 can have something to interrogate to learn what the process signature is and therefore what process data fields there are to map to. Once that configuration of the IPC event is complete, you can delete the stub KPRX.

 

Hope this helps!

 

S.

Badge +1

I got it working now thanks to your instruction.

 

Thanks a lot!

Reply