(ACL) Give a user read/write permission if the user is in the list field.

ESL
ServiceNow Employee
ServiceNow Employee

Hi, I have add a list type field which reference the sys_user table.
I can add some users into the list and let the users in this list able to read/write the record.

There are some OOTB ACL which is allow the user who created the record access the record.

"current.opened_by == gs.getUserID()" 

 

For example, for this "Who can access this record" field, Able, Abraham, Alejandra in this list, I would like let them to access this record.

find_real_file.png

How can I configure ACL by checking list type field? 
Please advice.
Thanks

1 ACCEPTED SOLUTION

Jaspal Singh
Mega Patron
Mega Patron

In the ACL script you need something as below

answer=false;
if(current.u_who_can_access.indexOf(gs.getUserID())>-1)
{
answer=true;
}
//replace the field u_who_can_access with correct dictionary name of the field

View solution in original post

6 REPLIES 6

dmathur09
Kilo Sage
Kilo Sage

Hi Easley,

You can use the condition builder in the ACL to give the mentioned condition. Refer below screenshot.

find_real_file.png

Let me know in case you have any further queries

If you think my response is helpful for you? If yes, mark it as correct answer and close the loop so that it would help future readers as well.

Regards,
Deepankar Mathur

ESL
ServiceNow Employee
ServiceNow Employee

Thans, I misunderstand "is(dynamic) Me" means "==", I just worried about if the user is not in the top of the list. But this way works very well. 

Helpful. Thanks,

 

Hi Easley,

Yes, so this will dynamically check, if it finds that "Who has access to the record" contains your name then it would allow you the access to the record. You won't need to do any scripting in here.

Please mark reply as Correct, if applicable. Thanks!

Regards

Deepankar Mathur

Jaspal Singh
Mega Patron
Mega Patron

In the ACL script you need something as below

answer=false;
if(current.u_who_can_access.indexOf(gs.getUserID())>-1)
{
answer=true;
}
//replace the field u_who_can_access with correct dictionary name of the field