- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2017 02:04 PM
Hi,
I have a workflow that requires:
1) Mgr Approval, then
2) Concurrent Approval by 2 separate groups (e.g. Network and Server Teams)
If the manager is a member of either of the subsequent approval groups, we would like that group's approval skipped.
I have figured out how to do this if there's a single group approval (Mgr > Network), by having an If statement before the Approval - Group. But I am not sure how to accomplish this if there are multiple approval groups, providing approvals concurrently.
Currently I have the Network and Server Teams' approvals in a Approval Coordinator, but am not sure how to skip one of the approvals. Should I create a condition script? Or should I not use the Approval Coordinator? My script to skip an approval (using an If statement) is as follows:
function ifScript() {
var mgr = current.variables.manager;
var groupName = "Network Approval";
var groupID = '';
//gs.log('****Mgr Name: ' + mgr);
//gs.log('****Group Name: ' + groupName);
//get Group sys_id
var grpGr = new GlideRecord('sys_user_group');
if(grpGr.get('name', groupName)) {
groupID = grpGr.sys_id + '';
}
else {
//we didn't find the group return false
return false;
}
//Determine if user is a member of the group
var grpMbr = new GlideRecord('sys_user_grmember');
grpMbr.addQuery('group', groupID);
grpMbr.addQuery('user', mgr);
grpMbr.query();
if (grpMbr.next()) {
//gs.log('****Query ran & returned Yes. User: ' + user + ' Group User: ' + grpMbr.user);
return 'yes';
} else {
//gs.log('****Query ran & returned No. User:' + user + ' Group User: ' + grpMbr.user);
return 'no';
}
}
Thanks!
Jessica
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2017 03:29 PM
Hi Jessica,
You can write advance script in Approval group activity,
var answer = [];
var mgr = current.variables.manager;
var networkGroupSysId= "Network Approval"; /// I would use sys_id as this groups are final and that will save me a database query to get sys_id
var serverGroupSysId = "Server Team";
if(isManagerMemberOfGroup(networkGroupName, mgr)
answer.push(networkGroupSysId);
if(isManagerMemberOfGroup(serverGroupSysId, mgr)
answer.push(serverGroupSysId);
function isManagerMemberOfGroup (group, mgr) {
//Determine if user is a member of the group
var grpMbr = new GlideRecord('sys_user_grmember');
grpMbr.addQuery('group', group);
grpMbr.addQuery('user', mgr);
grpMbr.query();
if (grpMbr.next()) {
//gs.log('****Query ran & returned Yes. User: ' + user + ' Group User: ' + grpMbr.user);
return true;
} else {
//gs.log('****Query ran & returned No. User:' + user + ' Group User: ' + grpMbr.user);
return false;
}
}
This way you will create on group approval which is needed.
Thanks.
PS: Hit like, Helpful, Correct and Endorse, if it answers your question

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2017 02:11 PM
Hi Jessica,
I think you could do this by scripting the approval groups themselves through the approval groups script. Instead of determining the group through the Group field you would write a script that determined which groups should be added to the approval. In that script you can check to see if the manager is a member of the group, and if so, not add that group to the approval.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2017 02:13 PM
hmm interesting.. two ways i can see to do this .. one would be an approval coordinator to create the approvals.. this might take a bit of scripting and i haven't used them much...
the second way would be easier to do in the workflow.. but harder for others to follow... initilize a wokflow variable of workflow.scratchpad.approved = true;
now after the managers approval put in a branch that goes to both approvals... and then to a join...
both approved branches for the approvals go to the join
both rejects go to a script box that sets item approved to false
now after the join put in an if... if workflow.scratchppad.approved = true... have a mark approved and move on to the rest of the workflow.
if it is false mark the item as rejected and handle like a normal rejection...
the trick here is to NOT set the state to rejected/approved by each individual approval but instead have it done by the if after the join..
AFTER the branch but before your approvals you put the if to test if the manager is in that group.. if so you just skip the approval and go to the join...
the kewl part is if the manager is in BOTH groups.. neither gets generated but since you defaulted to true for the approved.. it will approve it and move on.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2017 03:29 PM
Hi Jessica,
You can write advance script in Approval group activity,
var answer = [];
var mgr = current.variables.manager;
var networkGroupSysId= "Network Approval"; /// I would use sys_id as this groups are final and that will save me a database query to get sys_id
var serverGroupSysId = "Server Team";
if(isManagerMemberOfGroup(networkGroupName, mgr)
answer.push(networkGroupSysId);
if(isManagerMemberOfGroup(serverGroupSysId, mgr)
answer.push(serverGroupSysId);
function isManagerMemberOfGroup (group, mgr) {
//Determine if user is a member of the group
var grpMbr = new GlideRecord('sys_user_grmember');
grpMbr.addQuery('group', group);
grpMbr.addQuery('user', mgr);
grpMbr.query();
if (grpMbr.next()) {
//gs.log('****Query ran & returned Yes. User: ' + user + ' Group User: ' + grpMbr.user);
return true;
} else {
//gs.log('****Query ran & returned No. User:' + user + ' Group User: ' + grpMbr.user);
return false;
}
}
This way you will create on group approval which is needed.
Thanks.
PS: Hit like, Helpful, Correct and Endorse, if it answers your question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2017 05:20 PM
Thank you all for your posts. I think all of your recommendations would have worked. I ended up adding a script as Brad and Nisha recommended and made some slight modifications to the script Nisha provided.
Thanks again! It is working as expected!