The CreatorCon Call for Content is officially open! Get started here.

How can I check if the current login user has specific roles and he is the manager of a group

Alon Grod
Tera Expert

How can I make sure that only users with 'local_manager' role or user that is currently currently trying to edit the group members is the manager of that group will be able to edit?
I tried to user this advance acl both on write and create but its not working.

if (gs.hasRole('local_manager')) {
    answer = true;
} else if (current.group.manager == gs.getUserID()) {
    answer = true;
}
else {
	answer = false;
}

6 REPLIES 6

abirakundu23
Mega Sage

Hi @Alon Grod ,

 

How many groups you have? You can use above code & check the member of the groups with OR conditions.

 

if (gs.getUser().hasRole('local_manager') && (gs.getUser().isMemberOf(gs.getProperty("Group"))) ||  (gs.getUser().isMemberOf(gs.getProperty("Group1")))) // Group is the sys_Property name

answer = true;

else

answer = false;

 

 

Brad Bowman
Kilo Patron
Kilo Patron

Hi Alon,

This post explains what needs to be done

https://servicenowguru.com/system-definition/group-managers-manage-group-members/