
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2016 11:42 AM
In our Change workflow we have an initial approval by the assignment group. It's an OOB step called Technical Approvals. Our managers are not part of their groups. They have requested:
- That they (the managers) be part of the group
- That they have the ability to choose who on their teams can approve (they may not want the entire team to be an approver)
To facilitate this we added a true/false button to the user record called: u_change_assessment_approver
How can I tell the approval to look at the assignment group and send the approval request to only those users of that group who have u_change_assessment_approver marked true?
Additionally how can I have it also send that approval to the manager of that group?
Thanks all!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2016 01:52 PM
dooo sorry much easier.. this is in a change workflow right?? if so do this instead in a user approval script
- var answer = [];
- var counter = 0;
- var failsafe_sid = 'sid of change manager or whoever will approve if there are no active approvers';
- answer.push(current.assignment_group.manager.toString()); //this pushes the manager of the group to the approvers
- var users = new GlideRecord('sys_user_grmember');
- users.addQuery('group',current.assignment_group); //find members of the group
- users.addQuery('user.u_change_assessment_approver',true); //check to see if they are a change approver
- users.query();
- while(users.next()){
- answer.push(users.user.toString());
- if(users.user.active){
- counter++;
- }
- }
- if(counter == 0){answer.push(failsafe_sid)}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2016 11:45 AM
Build your approval via the advanced script in the approval. Use the GlideRecord query on the table sys_user_grmember to get the members of the team (that table has a group field and user field to make it easy to query.) Once you have retrieved a user, save it in the answer array only if it has that new field set to true.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2016 11:56 AM
Hi Issac,
Here is the sample script as per your req.
Script :
var answer = [];
var grusr = new GlideRecord('sys_user_grmember');
grusr.addQuery('group.name','PASS GROUP NAME HERE');
grusr.addQuery('user.u_change_assessment_approver','true');
grusr.query();
while(grusr.next())
{
answer.push(grusr.getValue('user'));
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2016 12:25 PM
Just a tweak grusr.user will get you the sys_id of the user. No need to dot walk to the sys_id field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2016 12:20 PM
ok i wouldn't do this as a group approval.. but as a user approval....
now i would build a script to push the approvals based on the group member table... and the group table.. first get the group record and add the group manager...
then thumb through the group member table for all of the members of the group get the user record and if they have the new field as true you add them
the one thing you will want to do is also verify the members are active.. and count the active people you add.. the way approvals work if there are no active approvers it is auto approved.. you will probably want a fail safe approver in case you end up with no active approvers.
when you use a group approval it is looking for GROUPS to add.. and you can't sort the people out.. when you use a user approval it is looking for a list of people to add.. so anytime you want only some members of a group you need to use a user approval not a group approval... let me know if you need more info on the tables to query.