This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - Code to skip workflow step if no approvers selected

bil4l - Tuesday, August 7, 2012 2:50 PM:

Normal 0 false false false EN-US X-NONE X-NONE

We are setting up a dynamic workflow that uses method code that Rob sent us to pull approvers off of an identity relationship and then assign the workflow step to them. We have 5 separate methods associated with each workflow step to pull the approvers off of the appropriate tab (1-5).
 
With this workflow we are designing, some of the time, the users may not have an approver at a given step. When this happens, the workflow assigns those nodes back to the workflow creator, rather than skipping the step altogether (which is what we would like it to do). We tried the automatic activity selection in conjunction with the method code, but that skips the step every time regardless of whether or not an approver was selected on the relationship tab. So it seems that the automatic activity selection takes priority over the “OnActivate” server event that is calling our method.
 Is there an alternative way to accomplish this that we may not have considered? We are thinking we might have to write some code into the methods that will move the workflow to the next step if there are no approvers selected in the relationship tab.
We are thinking that we may have to change the last step in this method to something that will set the next worklow node to automatic and then change it back, but we are struggling on how to accomplish this.
 
// Loop through the reviewer relationships and create assignments
reviewers = contItem.getItemsByXPath("Relationships/Item[@type='"+relName+"']");
for (int i=0; i<reviewers.getItemCount(); i++)
{
     string identId = reviewers.getItemByIndex(i).getProperty("related_id","");
     Item assignment = this.newItem("Activity Assignment","add");
    assignment.setProperty("source_id", actId);
    assignment.setProperty("related_id", identId);
    assignment.setProperty("voting_weight", "100");
    assignment.setProperty("is_required", "1");
    assignment = assignment.apply();
    if (assignment.getItemCount() != 1) return inn.newError("Error creating assignment: "+assignment.getErrorDetail());    
}
 
Thanks,
Bill


newcomer - Thursday, August 9, 2012 9:14 AM:

two ways came to my mind when i read your post:

1: an onActivate method thats promotes the workflow to the next step if the assignee is the "workflow creator".

2: you have to change the workflow: before each workflow-approval-activity you can add a auto activity connected with the approval activity and the activity after the approval activity. the auto activity checks if an assignee is set for the approval activity or not and decides which road the item will take in the workflow.