Omit new button based on role

G Balaji
Kilo Guru

Hello,

We've a custom table in our custom application.

"New" button in list layout has to be hidden for all the users except "admin".

I tried using "Omit New button" using the followin script but for some reason it's not working.


var userRole=gs.getUser().getRoles();

if(userRole=='admin'){
answer=true;

}
else
answer=false;

 

Any pointers on this?

 

 

 

1 ACCEPTED SOLUTION

Michael Fry1
Kilo Patron

I think your script is backwards. You want answer to be false if admin role;

answer = ifScript();
function ifScript(){
	if(gs.hasRole('admin')){
		return false;
	}
	return true;
}

View solution in original post

2 REPLIES 2

Allen Andreas
Administrator
Administrator

Hi,

I'd recommend using ACLs for this. Look at your table and the "create" ACL and apply script logic there.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Michael Fry1
Kilo Patron

I think your script is backwards. You want answer to be false if admin role;

answer = ifScript();
function ifScript(){
	if(gs.hasRole('admin')){
		return false;
	}
	return true;
}