Default Escalation with custom code

  •  02-24-2008, 4:26 AM

    Default Escalation with custom code

    Hi there,

    First message in this forum, although I have read a lot of the threads here.

    Short story: Using code in K2, how do I enumerate through all instances of an activity and how do I force an instance to "Finish"?

    Long story:
    Ok, I have the following situation: Activity "A" which leads to "B" or "C", depending on the outcome. "A" is a multi-slot activity. In other words, it is being sent to a number of people (let's assume 5). For each one of those people a slot is being created. They have to basically choose "Yes" or "No" (Approve or Reject).

    "A" leads to "B" if ALL SLOTS = Yes

    "A" leads to "C" if AT LEAST 1 SLOT = No AND ALL SLOTS ARE NOT EMPTY (I have set a default value to Action Result which I check for).

    So basically, everything works perfectly. The opinion of every participant matters and the workflow is not moving to the next step, before everyone 'votes'. However, an enhancement has to be introduced. After a period of time (let's say 2 days) all slots (participants) who have not selected "Yes" or "No" need to be deleted, as they never existed. Or, just force them to "finish" and default to "Yes". I have figured out most of it - use Default escalation and click "View Action code", but I am not sure what code exactly to write. I don't know how to enumerate through all of the instances of the activity, neither how to force it to "Finish". Here is what I have tried, but it doesn't work at all. I don't know if it's enumerating right and the Status property is read only :(

     
    for (int i = 0; i < K2.ActivityInstance.Destinations.Count; i++)
    {
      if (K2.ActivityInstance.Destinations[i].Status == ActInstDestStatus.Active)
      {
        K2.ActivityInstance.Destinations[i].DataFields["Action Result"].Value = "Approved";
        K2.ActivityInstance.Destinations[i].Status = ActInstDestStatus.Completed;
      }
    }

     Any help is highly appreciated!

     
    Thanks,

    Hristo


     


    Hristo Yankov
View Complete Thread