Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to restrict Edit button in the related list based on role and state field?

Community Alums
Not applicable

Hello,

I want to restrict the edit button in the related list of incident available on the Problem form.

find_real_file.png

For user with “problem_requester” role the edit button should only appear when the state is “New”. For the rest of the users with role like Problem_manager, admins it should be visible all the time. I have tried to edit the list control but it is not working as it should be.

Edit roles added in the list control:

find_real_file.png

Scripts in omit edit condition:

find_real_file.png

wherein 1 is a value of New.

But the problem is servicenow considers only first condition “parent.state != '1' “ and ignores “gs.hasRole('problem_requester')” resulting access restriction for the admins as well when state is not new.

Please help to resolve this issue.

Thanks & regards,

Jainil Shah

1 ACCEPTED SOLUTION

VigneshMC
Mega Sage

Try this 

 

if ((parent.state==1 && gs.hasRole('problem_requester')) || gs.hasRole('admin') || gs.hasRole('problem_manager')){
	answer = false;
}else
	{
		answer = true;
	}

View solution in original post

2 REPLIES 2

VigneshMC
Mega Sage

Try this 

 

if ((parent.state==1 && gs.hasRole('problem_requester')) || gs.hasRole('admin') || gs.hasRole('problem_manager')){
	answer = false;
}else
	{
		answer = true;
	}

Anurag Tripathi
Mega Patron
Mega Patron

Id suggest that you dont use Edit Roles, put everything in the Omit Edit Conditions. That would give you more control.

-Anurag