Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2023 04:16 AM
My requirement is to restrict visibility of catalog based on the group. We want dynamic script so that only *SDM groups can see that items. any lead will be helpful
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2023 06:41 AM
Hello Milind,
You can try this code in script part of User criteria :
/** Scripted User Criteria is not cached, and evaluated everytime, so performance is dependent on the script.
* Populate `answer` with true/false or evaluate to true/false
* The script is evaluated in the scope the user criteria is defined
* Don't use `current` in the script or populate the variable
* Don't use `gs.getUser()` or `gs.getUserID()`,
* instead use `user_id` which contains the user sys_id against whom the evaluation is happening.
*/
answer = isUserMember(user_id);
function isUserMember(user_id) {
var isMember = false;
var gpMember = new GlideRecord("sys_user_grmember");
gpMember.addEncodedQuery('group.nameLIKESDM^user=' + user_id);
gpMember.query();
if (gpMember.next()) {
isMember = true;
}
return isMember;
}
You can check this using 'User Criteria Diagnostics'
Vishal Birajdar
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2023 08:20 PM
Thanks
It is working perfectly fine