field is read only for everyone except 2 groups

New user1212
Tera Contributor

Hey, I've created a new field in the form and I want it to be read only to everyone but that two groups can have access to filter this field - it's a reference. I want to create an acl for this case but I don't know the best way to do it. What would be the best way?

6 REPLIES 6

Murthy Ch
Giga Sage

Hi @New user1212 

You mean to make field editable for two group members?

If yes you can create write level ACL on the field and in script section use below logic:

 

if(gs.getUser().isMemberOf("sys_id of the group 1") || gs.getUser().isMemberOf("sys_id of the group2"))
answer=true;
else
answer=false;
answer;

 

 

Thanks,
Murthy

That's what I was thinking, but I'm having trouble with the code. thank you very much

Sagar Pagar
Tera Patron

Hi @New user1212,

 

You can try with Data policy with condition Assignment group is not group1 or group2.

Make the field as read-only true.

 

Thanks,
Sagar Pagar

The world works with ServiceNow

Sumit Singh
Tera Expert

As per my knowledge, you can create a new role and map that role with groups.
And you can create an ACL for that new field and map the newly created role into it.

Thanks
Please mark it as helpful if it works for you.