ABC group members is not part of Level 1 and Level 2 cost center users
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2023 11:56 PM
Hello Experts,
My requirement is
I want users details in a report who is part of ABC group is not part of cost center table Level1 approver(reference field) and level 2 approver(reference field).
So I created script include but when i run report it is taking so much of time to get results and instance also not working
In report the condition is sysID is javascript: TestL1L2Approver();
Is there any mistake in my script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2023 12:02 AM
you can optimize the script as this
function TestL1L2Approver() {
var mem = [];
var grMembers = new GlideRecord('sys_user_grmember');
grMembers.addQuery('group', 'e5302b2d1b4e11506ece2fc5604bcb5c');
grMembers.query();
while (grMembers.next()) {
var userSysID = grMembers.user.toString();
var Levelone = new GlideRecord('cmn_cost_center');
Levelone.addQuery('u_level_1_approver','!=',userSysID);
Levelone.addQuery('u_level_2_approver','!=',userSysID);
Levelone.query();
if (!Levelone.next()) {
mem.push(grMembers.user.toString());
}
}
return mem;
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2023 12:11 AM
Hello @Ankur Bawiskar
For testing purpose i have added 5 test users in group.
But that script is not working
Best Regards,
Raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2023 12:17 AM
you need to use filter IS ONE OF
also return mem.toString()
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2023 12:22 AM - edited 09-04-2023 12:23 AM
Hello @Ankur Bawiskar
used IS ONE OF filter and added return mem.toString() but no luck.
please try it once from your end.
Thanks in advance
Best Regards
Raj