- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2022 02:47 PM
The script I need help with runs in the Approval Workflow for SM. And it returns an array of approvers based on the Location Selection. Some groups take care of Locations and within those groups, users with the approval role.
I need help with a script that will do the following to create approvals for Work Orders.
I have a function that already returns the group's sys id like this: sys_idIN45646546546546546546546s54dfs6df4
My requirements:
- Run this function against the
- var groups = new global.SMFilters().filterGroups(current.sys_class_name, current.location, 'dispatch');
- Remove the sys_idIN and push any following groups into an array
- Once the groups are in an array, go get all the members of those groups and push them into an array
- Make the grMembers array unique (ArrayUtil.unique)
- Loop through the uniqueMembers and check to see if they have the approver role
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2022 04:13 PM
What did not work?
Please try above code in background script with the correct test data it will surely work.
PFA in my PDI.
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2022 03:21 PM
Hi @morrix3,
Below code is as per your requirement
var groups ="sys_idIN0002648a87b25d509850ed390cbb3511,0012ec8a87b25d509850ed390cbb35f8";//Test Data
var grpMemArr=[];
var grpMem= new GlideRecord('sys_user_grmember');
grpMem.addEncodedQuery('group.'+groups+'^user.roles=approver_user');
grpMem.query();
while(grpMem.next())
{
grpMemArr.push(grpMem.getValue('user'))
}
var au=new ArrayUtil();
gs.info(au.unique(grpMemArr))
Regards
Saurabh
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2022 03:51 PM
Saurabh:
I appreciate your help.
It didn't work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2022 03:57 PM
What did not work?
Please try above code in background script with the correct test data it will surely work.
PFA in my PDI.
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2022 04:13 PM
What did not work?
Please try above code in background script with the correct test data it will surely work.
PFA in my PDI.
Thanks and Regards,
Saurabh Gupta