- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2022 08:04 AM
Hello,
I am creating a business rule in which I need to check if current logged in user is member of any of the child groups of a certain parent group.
And if user is a member of any of them groups, then code can continue and display the appropiate message.
How can I achieve this please. need code help
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2022 08:09 AM
Hello
you can try this
var arr=[];
var gr = new GlideRecord('sys_user_group');
gr.addQuery('parent','your_parrent_group_sys_id');
gr.query();
while(gr.next())
{
arr.push(gr.name.toString());
}
for(var i=0; i<arr.length; i++)
{
if(gs.getUser().isMemberOf(arr[i]))
{
//continue your code
}
}
PLEASE MARK MY ANSWER CORRECT IF IT HELPS YOU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2022 08:07 AM
Hi Khalnayak,
For this requirement you can utilize gs.getUser().isMemberOf('<sys_id_of_group>')
It is up to you, whether you use this multiple times in condition of business rule or call a script include in the condition.
Hopefully, this will help you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2022 08:08 AM
I need to check if user is member of the child groups for a parent group.
will isMemberOf check if user is member of that group or any nested groups too?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2022 08:30 AM
It will only check for a group for which you have specified the sys_id. If you already know the child groups, then you can use their sys_id in the above function.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2022 08:09 AM
Hello
you can try this
var arr=[];
var gr = new GlideRecord('sys_user_group');
gr.addQuery('parent','your_parrent_group_sys_id');
gr.query();
while(gr.next())
{
arr.push(gr.name.toString());
}
for(var i=0; i<arr.length; i++)
{
if(gs.getUser().isMemberOf(arr[i]))
{
//continue your code
}
}
PLEASE MARK MY ANSWER CORRECT IF IT HELPS YOU