Setting up Create, Read, Write and Delete ACL's

Andre241
Tera Contributor

I've created a table called "Dream" I created a user role called Dream user to with the following ACL's: Create, Read, Write and Delete. I need the user to be able to create, delete and edit their own record but be able to read others. I created the following acl's but they don't work. Any assistance would be great. 

Write ACL:

Andre241_0-1665447969910.png

 

Create ACL:

Andre241_1-1665448008517.png

 

Delete ACL:

Andre241_2-1665448115460.png

 

Read ACL: has no script

Andre241_3-1665448154496.png

 

8 REPLIES 8

Sateesh Kumar D
ServiceNow Employee
ServiceNow Employee

Hi Andre,

 

Create and read ACL can have only role attached to it with no script. Create is executed only when a person creates a new record which is anyway of their own so it should be fine.

For create and delete add the required role on role section and in script try below

answer = false;

if (current.sys_created_by.equals(gs.getUserName()))
answer = true;

 

Regards,

Sateesh Kumar Devadoss

Is there a condition to add? Because it didn't work

 

answer = false;

if (current.sys_created_by.equals(gs.getUserName()))
answer = true;

Andre241_0-1665488094559.png

 

No condition need to be added.

can you mention which part is not working? State the Steps you are performing, actual result and expected result so that I can help.

@Sateesh Kumar D 

 

I expect a user with either of these two roles x_380276_dreams.userx_380276_dreams.admin, to be able to create a record on this table x_380276_dreams_dreams. They should be only able to delete or edit their own record and not others. They should also be able to read others created record. 

This is what I have for delete admin role

Andre241_0-1665496947833.png

Dream.user role delete ACL:

Andre241_1-1665497016928.png

Those are just examples for delete and here is the script I'm using for both "Delete and Write"

answer = false;
if (current.sys_created_by.equals(gs.hasRole('x_380276_dreams.user')))
answer = true;