Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Restricting view of Incidents (ACL)

jayson5
ServiceNow Employee

Hello Community,

The Incident form has a lot of ACLs, However I need to lock down All HR Incidents to users with an HR Role...I've put the following in for a Read ACL, however it locks everyone out of the Incidents

if the "Functional Area" = Human Resources I want to restrict those Incidents to only users with that role

ACL Script:

current.u_functional_area = 'HUMAN RESOURCES';

Requires Role:

HR

33 REPLIES 33

Anurag Tripathi
Mega Patron

Use this script only in Read ACL



if(current.u_functional_area = 'HUMAN RESOURCES' )


{


if(gs.hasRole('HR'))


answer=true;


else


answer=true;


}


-Anurag

Hi Anurag,



I get the following,


WARNING at line 1: Expected a conditional expression and instead saw an assignment.


You will have to use '=='   when you are comparing inside the if condition


Change to this "if(current.u_functional_area == 'HUMAN RESOURCES' )"



thanks,


Abhinay



if(current.u_functional_area == 'HUMAN RESOURCES' && gs.hasRole('HR')){


answer = true;


}


else{
answer = false;
}


-Anurag

sudharsanv36
Mega Guru

Hi Jason,



Try like this, remove the requires role record.



In the script section


if(current.u_functional_area = 'HUMAN RESOURCES' && gs.hasRole('HR')){


answer = true;


}


else{
answer = false;
}



I believe "u_functional_area" is a String/Choice field.



Please mark it this helpful/correct if you were able to solve the issue.