Check logged in user is belongs to anyone of these Department or not
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 02:33 AM - edited 07-21-2023 03:46 AM
Hi All I have these departments starting with IOT I need to check whether the logged-in user belongs to these departments or not if he belongs to any one of these departments we return the value true others wise false how we can achieve with client script and script include.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 02:39 AM
Hello @Somasekhar6
var grp = new GlideRecord('sys_user_group');
grp.addQuery('nameLIKEIOT');
grp.query();
var flag=0;
while(grp.next()){
if(gr.getUser().isMemberOf(grp.sys_id)){
flag=1;
}
}
if(flag==1){
return true;
}
else{
return false;
}
Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.
Regards,
Samaksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 02:53 AM
@Samaksh Wani it's not a group department of the user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 03:00 AM
Hello @Somasekhar6
This is the updated script for department.
var grp = new GlideRecord('sys_user');
grp.addQuery('departmentLIKEIOT');
grp.query();
var flag=0;
while(grp.next()){
if(gr.getUser().isMemberOf(grp.department)){
flag=1;
}
}
if(flag==1){
return true;
}
else{
return false;
}
Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.
Regards,
Samaksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 03:25 AM - edited 07-21-2023 03:30 AM
@Samaksh Wani Not getting expected result