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.

set field to read only if user viewing the record is not in a certain group

DreDay3000
Tera Guru

I would like to set the requested for field to read only if the current user is not a member of a specific group. Or does not have a specific role

1 ACCEPTED SOLUTION

AshishKM
Kilo Patron
Kilo Patron

Hi @DreDay3000

Write client script on that table like below.

 

you can use g_user.hasRole('itil'); for checking any role ... replace the itil with desire role. 

 

function onLoad() {
     var usr = g_user.getUserID();
 // set the correct grouop name
  if (!usr.isMemberOf('<group>')){
  g_form.setReadOnly("requested_for",true)

 }

 

-Thanks,
AshishKM


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

View solution in original post

1 REPLY 1

AshishKM
Kilo Patron
Kilo Patron

Hi @DreDay3000

Write client script on that table like below.

 

you can use g_user.hasRole('itil'); for checking any role ... replace the itil with desire role. 

 

function onLoad() {
     var usr = g_user.getUserID();
 // set the correct grouop name
  if (!usr.isMemberOf('<group>')){
  g_form.setReadOnly("requested_for",true)

 }

 

-Thanks,
AshishKM


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution