- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2023 12:35 AM
Scenario:
If a Assignment group has manager empty then for those users we should restrict the visibility of Emergency Change Model in Change Landing Page. In vice versa If Assignment group has manager not empty then for those users Emergency Change model should be visible in Change Landing Page. I added the below code under Available for related in Change model user criteria
var rec = new GlideRecord('sys_user_grmember');
rec.addQuery('user', user_id);
rec.addEncodedQuery('group.managerISNOTEMPTY');
rec.setLimit(1);
answer = rec.hasNext();
The above code also didn't work ..no logs were also displayed even when i gave log messages. Can you please help me what's the mistake in code and why my change model is not been restricted properly
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2023 01:19 AM
Hello @Ashwin Perumal1 ,
Use this script-
answer = false;
var user = gs.getUserID();
var rec = new GlideRecord('sys_user_grmember');
rec.addEncodedQuery('user='+user+'^group.managerISNOTEMPTY');
rec.query();
if(rec.next())
{
answer = true;
}
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2023 09:28 AM
Hello @Ashwin Perumal1
It will work for the all scenarios. If user is part of any group and that group is having manager then it will work.
If that user is a member of multiple group and all the groups are not having manager then it will not be visible.
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2023 01:19 AM
Hello @Ashwin Perumal1 ,
Use this script-
answer = false;
var user = gs.getUserID();
var rec = new GlideRecord('sys_user_grmember');
rec.addEncodedQuery('user='+user+'^group.managerISNOTEMPTY');
rec.query();
if(rec.next())
{
answer = true;
}
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2023 07:25 AM
Hi Harsh,
The above script works in one scenario if the user is part of one group. In that case it works fine. But coming to other scenario if a user is part of multiple groups and one group he is having manager and another group he is not having manager in that case the above script its not working as expected.
If a user is having atleast manager in any one of the groups he is tagged then in that scenario also my Change model should be vissible. Can you pls help me to code the mentioned scenario. Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2023 09:28 AM
Hello @Ashwin Perumal1
It will work for the all scenarios. If user is part of any group and that group is having manager then it will work.
If that user is a member of multiple group and all the groups are not having manager then it will not be visible.
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2023 09:44 PM
Thanks Harsh it worked fine