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:31 AM
is the script include client callable and in same scope as that of the report?
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:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2023 12:40 AM
did you try running the same script in background and check if the array contains any users?
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 04:04 AM
Hello @Ankur Bawiskar
Now if I run report, I can see only one user sys_id is coming but he is part of L1 approver. I changed the condition as well . But no luck.
Please help me to achieve this requirement
Best Regards,
Raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2023 04:14 AM
try 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.query();
while(Levelone.next()){
if(Levelone.u_level_1_approver != userSysID && Levelone.u_level_2_approver != userSysID)
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