Skip to main content

When leveraging destinations sets that sometimes may resolve to no users at all, a failsafe destination set must be included in the activity to handle this contingency.  Depending on the type of destination set, when empty, you may receive "object not set to an instance of an object" or other errors.


From a business user's perspective there are two avenues that can be taken:
   1)  Always have a failsafe group that should be handling activities of the given type such as your "Support" or "Human Resources" group in AD.
   2)  Have a general administrative group that is responsible for handling orphaned activities.  This group can provide direct feedback to your development team so that the orphan scenarios are handled properly with business rules as opposed to just adding the orphans to particular group's general worklist (queue).


In either case, the easiest implementation of a destination set strategy is to define process level datafields pertaining to each destination set within each activity.  For instance, in my SupportRequests workflow I have the following fields for destinations regarding the SupportRequestActions activity:
- SRActionsGroupName (intended to contain the AD Group to be assigned to the activity)
- SRActionsSingleUserDestination (intended to contain the AD username to be assigned)
- SRActionsCustomDestination (intended to be flagged "True" if a custom destination set is written to the SmartObject)


If the "SRActionsCustomDestination" field is flagged as True, then the Destination Set "Custom"'s rule will resolve to true and the destination set will be read from the SmartObject using a statement that in essence is
   "Select DestinationUser from SmartObject where ActivityKey = 'Activity.Name+ProcessInstance.ID' "


Again, if our "Custom" destination set ("Select DestinationUser...") doesn't bring back any records, we will get an error in the process, so we must populate the flag field only if records are successfully written to the SmartObject.  The easiest way to demonstrate this is via a try/catch block like I've used in this example:

 try
{
     foreach (string strDestination in arrDestinations)
     {
           if (strDestination.Length > 0)
           {
                  Example.CustomDestinationsClass.Methods.CreateDestination(
                            m_strSOConnCustomDestinations,
                            oWli.ActivityInstanceDestination.Name + oWli.ProcessInstance.ID.ToString(),
                            oWli.ProcessInstance.ID,
                            strDestination);
           }
       }
       oWli.ProcessInstance.DataFieldsl"SRActionsCustomDestination"].Value = true;
}
catch
{
       oWli.ProcessInstance.DataFields "SRActionsCustomDestination"].Value = false;
}
note: this code is presented in it's entirety in article http://k2underground.com/forums/post/19052.aspx


Then, add one last destination set to activity which will contain your failsafe value.   The destination rule should look at each of your previous destination rules and if none of them resolved to true, then itself resolve to true.  It will look something like this:


original.aspx

Be the first to reply!

Reply