omit edit button on group table level

LaraReddy
Tera Guru

Hi All,

we want that only the Group owner can see and use the "edit" button on the related list "Group Members". Therefore we edited the List control and added following omit edit button script.

But some reasons it's not working, can anyone please help us here.

LaraReddy_0-1708606725158.png

 

Advance thanks.



30 REPLIES 30

@LaraReddy 

try this

var currentUser = gs.getUserID();
var groupManager = parent.group.manager.toString();
var isAdmin = gs.hasRole('admin');
if(currentUser == groupManager || isAdmin)
	answer = false;
else
	answer = true;

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,
Thanks for the response.

Tried your script but no luck, still the group's  managers are not seeing the Edit option.

LaraReddy_1-1708619837761.png

 




@LaraReddy 

what came in log for parent.group.manager?

Are you sure the group has manager populated?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,
We have replaced parent with current then we're seeing the manager sys_id in logs and it's working fine .

But the Edit is option is showing only if the users are available in groups.

I mean let assume that if there is no users in group and if same group's manager opened the group to add the users , In this scenario the Edit option is not showing.

 

var currentUser = gs.getUserID();
var groupManager = current.group.manager.toString();
gs.log('manager: ' + groupManager + 'currentUser: ' + currentUser);
var isAdmin = gs.hasRole('admin');
if (currentUser == groupManager || isAdmin) {
    answer = false;
} else {
    answer = true;
}



Advance thanks.

@LaraReddy 

is the group manager a group member also?

Also is the group having manager field populated?

Script looks good to me

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader