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 field read only based on Roles.

varma2
Mega Sage

Hi All,

 

User whoever having a role ( uis_srvacc_exception_admin ) they only can able to edit field ( SrvAcc Exc Details ) even Admin role user also shoud not able to editible, for that we have field level write ACL to edit the field and below is the script.

 

if (gs.hasRole('uis_srvacc_exception_admin') && !gs.hasRole('admin')) {
answer = true;
}

else {
answer = false;
}

 

Above script was not working for all the scenarios, for example If the user having only ('uis_srvacc_exception_admin') role its works and filed are editable.

But  if the user have both roles ( ADMI role and also "uis_srvacc_exception_admin) in this scenario field not editable for who ever having the uis_srvacc_exception_admin role.

It should work even if Admin users if user has the ''uis_srvacc_exception_adminrole. Without this role it should not work.

Please sugeest.

 

Thanks all.

 

 

2 REPLIES 2

RaghavSh
Mega Patron

1. Make your ACL admin override  true and below changes to script:

 

if (gs.hasRoleExactly('uis_srvacc_exception_admin')) {
answer = true;
}

else {
answer = false;
}


Raghav
MVP 2023
LinkedIn

Hi Raghav,

 

I have impliment above your code and chacked the admin over ride,But field did not editble if the user having  uis_srvacc_exception_admin role.

 

Please suggest.

 

Thanks,

Varma