Skip to main content

I have an activity (which calls a sub-process) with a destination rule of 'Plan per slot (no destinations), 'Select a list field to determine how many slots should be created'. This does a lookup to a sharepoint list. And all works well.


If I have 2 items in my list, all events in my activity are called twice (and 2 sub-processes are triggered.)  One of these activities is to create a record in a SQL database and save the ID of this record for an update later in the activity. Again this works fine.


For escalations, I have created an 'Escalation After Rule' with a 'Default Action'. I have then written a c# Action Code which uses this ID and updates a value for it in the SQL database if  it escalates. This update should be slot specific.


The ID is created as an Activity Data Field and when it is used at event level it works well. BUT in my escalation code it cannot find it. I reference it using the following:   K2.ActivityInstance.DataFieldsa"ID"].Value.ToString();


I've read BLACKTOP's article on Data Field Scope (http://www.k2underground.com/blogs/blacktop/archive/2009/03/30/data-field-scope.aspx) and it says that '• Activity destination instance data/xml fields are in scope only during activity in which they reside but there is one copy of the field for each slot in the activity' which is exactly what I need. However, it won't let me code at activity destination level.


I've changed the data field to be 'shared' and the code can then find the ID activity data field but then updates the ID of just one of the slots  (presumably because 'shared' means there's only one copy of the data per activity?).  


It can't find the ID even if there's only 1 item in my SP list and only 1 slot.


Any help gratefully received. Thank you.              


 

In your code snippet you are still refering to the activity instance field, not the activity destination instance field.  Activity instance = 1 field per activity regardless of slots.  Activity Destination Instance = 1 field per slot.


Thanks David, but it won't allow me to code at Activity Destination Instance level, only ActivityInstance or ProcessIntance.


I think I see now.  You have an activity level escalation.  What you need is an eveny level escalation.  Client events have these, but it looks like the IPC does not.  I think there are a couple of ways to handle this, starting with the easiest first.


1.  Put a process-level escalation on the child workflow so that if it does not complete on time you can update the SQL table.  This way the escalation occurs only on those that have not completed and you don't have to do anything to ignore those that have already completed.


2.  If you still want to put it on the IPC activity, you could use K2.ActivityInstance.WorklistSlots.DataFieldst"ID"]. 


I'd probably lean towards #1 if it otherwise met the requirements.


It's so obvious now you've said it!! Thank you so much David - will do option 1.  So there is only 1 instance of the activity and the number of slots determines how many instances of each event there are.... Really appreciate your time on this. Thank you!


Reply