Skip to main content

I am new to K2!

 I am trying to create a unique folio name for an IPC event. I have modified the Destination Rule to do this by using the GetVendorID function I created. This sets the slotInstanceDataa] variable to be something like "VendorID:001185". I want to use this value as the Folio name. I need to pass the VendorID value into the child workflow. I tried using the ActivityInstanceDestInstanceData field in Folio field but it appears to be empty. My thought was to pull the VendorID from the Folio field and pass that to the child process.

Destination rule code from wizard...
if (K2.Configuration.DynamicSlots)
... 
for (int i = 0; i < slotCount; i++)
{
 slotInstanceData = initData + ":" + GetVendorID(i);
}
}
K2.Slots = slotCount;
K2.SlotInstanceData = K2.Configuration.SlotInstanceData;


The bottom line is I need to pass a unique VendorID value into a child process. All of the data I am using is coming from repeating elements.


Partial xml data
<Vendors>
 <Vendor>
  <CompanyName>Bonney Forge</CompanyName>
  <VendorID>004591</VendorID>
  <Manufacturer>Bonney Forge</Manufacturer>
 </Vendor>
 <Vendor>
  <CompanyName>Mid-States Supply Co.</CompanyName>
  <VendorID>001185</VendorID>
  <Manufacturer>Velan</Manufacturer>
 </Vendor>
</Vendors> 


Hope this makes sense to someone. Any ideas would be appreciated.

When Defining IPC, there is option to pass the values from Parent process to Child process. Create a new datafield "VendorId" in your process. Assign VendorId datafiled in your IPC which will be passed from PArent to child process.

In the activity Where you have IPC event,

1.)add one server event before that.

In Newly added server event Assign the Datafield "VendorId" to the value, Now when IPC event will be executed , Datafield VendorId will have the desired value and will be passed on to child process.

OR 

2.) In destination rule code, assign the datafield value to the desired value. 

I am sure there will be many other ways but this is the one which came to my mind first!

 


OK, I understand the concept I'm just having problems getting it done. I think option 2 is the one for me. I added the following code inside the destination rule for the Create Suppplier Sites activity (see attachment)


for (int i = 0; i < slotCount; i++)
{
  slotInstanceData = initData + ":" + GetVendorID(i);
  K2.ActivityInstance.DataFieldsd"VendorID"].Value = GetVendorID(i);
}


When running I get an error that states the VendorID field could not be found. I have added the VendorID field in the K2 Object Browser under Data Fields / Activities / Create Supplier Sites (Create Supplier Sites is the activity that calls the IPC Event). I have attached an image from VS.


Thanks again for the quick response.


12742i1673D4C37E645B23.jpg

Well, As per your diagram, you are assigning the Activity Data field in one activity and accessing it other activity. It will throw error kind of "Variable out of scope"

So, when you declare activity level datafield it is accessible only in one activity, not available in other activity.
 

I would say create VendorId a process level datafield. By doing that scope of data field will change from activity to process and then you can use

K2.ProcessInstance.DataFieldss"VendorID"].Value ="Value"

To Create a process level data field do following:

Open K2 Object Browser- >Select Data Fields --> right click the process name and Add Data field. 


Thanks for the help. I was having trouble understanding how destinations are handled. Adding the server event in front of the IPC Event did the trick.

Reply