How to restrict a record producer available for only with the groups with the parent company as ABC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-27-2023 10:26 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2023 03:30 AM - edited ‎03-28-2023 03:33 AM
Means you want to show the record producer to logged user if that user is member of that group right?
if yes then try below code
checkUsers(gs.getUserID());
function checkUsers(user){
var userGrp = new GlideRecord('sys_user_group');
userGrp.addEncodedQuery("u_par_company=ABC^active=true");
userGrp.query();
while (userGrp.next()){
var grMember = new GlideRecord('sys_user_grmember');
grMember.addQuery('group',userGrp.sys_id);
grMember.addQuery('user',user);
grMember.query();
if(grMember.next){
return true;
}else {
return false;
}
}
}
Declare the answer variable in your code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2023 04:11 AM
still not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2023 04:57 AM
There is no active field on group table so try the below code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2023 05:22 AM
Is company field on group table is refence filed? if it is reference field then add below query