Group Approvals Using Check Box Variables Help Please.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2013 04:40 PM
I was wondering if anyone was able to help me with my situation. I have a Catalog item with multiple check-boxes, these check-boxes are to select which approval groups are to be used on the Workflow. There must be ability to select multiple boxes. When reading though documentation i am fairly sure that this needs to put in the Advanced Section under approval groups Seen below. However i am a novice at scripting and without learning all of JavaScript outright i was wondering if someone could give me a primer of how the variables should look in the case below.
// Set the variable 'answer' to a comma-separated list of group ids or an array of group ids to add as approvers.
//
// For example:
// var answer = [];
// answer.push('id1');
// answer.push('id2');
This is along the lines of what i have tried.
var answer = [MRMSS IRQM Approvers]
answer.push('IRQMApprovers')
I have attached all the screenshots that might be able to help you determine how our groups are named and the names of the variables. Any help would be greatly appreciated.
Casey-
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2013 05:39 PM
Checkboxes are essentially True/False values. Checked = True, not checked = false.
A bit about what the sample code does:
answer = [];
You are going to want to leave this line as is. What this does is make a variable named 'answer' and the variable is assigned an empty array.
answer = [];
answer.push('id1');
.push() is an array method. It basically says, hey take the value id1, and push it on into the answer array. Arrays can hold many items. At this point, answer is holding id1.
What you could do, is make id1 a variable of a certain manager or approver.
answer = [];
var id1 = current.requested_for.manager; //sys_id of the requestor's manager.
answer.push(id1);
...but for your case it doesn't make sense. You are looking for groups, not an individual. So what I would do is in the work flow have a chain of 'If Statements' with each leading to a Group approval action. Please see my attachment for what I mean.
The real work in this case is done by the If statements. You will want to check the 'advanced' box on these, and get the values of the checkboxes. Use the values of the checkboxes to determine which path the If statement will take, it will either "return 'yes'" or "return 'no'".
In the group approval action all you have to do is specify the group, you dont have to use the advanced option to script it in. Please see my other screenshot (sample-Group1Approval.JPG) for what I mean.
This might help with the If statement scripting:
//sample if statement code:
var test = current.IRQMApprovers; //get the value of the IRQM checkbox.
//test is either true or false depending on if the user clicked the IRQM box.
if ( test == true ) { //user checked true for IRQM Approvers
return 'yes';
}
return 'no';
//so if return 'yes' then advance to the IRQM approver group approval, if not,
//then go to the next if statement to check if group2 approval checkbox was checked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2013 10:16 PM
Thank you so much, this will get me started if i truly want to go with this option.
Since i now know this is the hard way to do it, what would you recommend?
I was thinking of putting a List Collector(slushbucket) on the item were they could choose what approval groups they needed but i was unable to get that to correlate to the group approvals box.
Do you think this would be a good method, if so what should i look at going with to link it up. Or maybe suggest another method. Thanks again for all the work and thought you have put in this.
Casey-