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.

Write ACL to allow user write access to their own records

mkader
Kilo Guru

Hello,

 

I have a new field I have created on the user table. This field will only be able to be written to by Admins and through a record producer we have on our portal (record producer does not create record, it does update). I need an ACL that only allows Admin to write too. I have a custom role that will only have read access. If a user is trying to update their record from the back-end on the user table, they should also have access.

Currently, I have everything setup. I have a write ACL for Admin only, so no other users can make modifications. Now I need to add something that will allow current users to make modifications to their own records.

Thanks!

1 ACCEPTED SOLUTION

Pranesh072
Mega Sage

You can add following code in acl script 

 

if (!gs.hasRole('admin')&& gs.getUserID() !== current.getValue('some user field on record')) {
	answer = false;
} else {
	answer = true;
}

View solution in original post

9 REPLIES 9

@mkader, I tried with below script but it is not working, so could you please assist me on this.

 

Ashok59_0-1705771746079.png

 

 

Regards,

Ashok

@Pranesh072 , I tried with below script but it is not working could you please assist on this.

 

Ashok59_0-1705772271580.png

 

Regards,

Ashok.

 

@Ashok59 owned_by is reference field. gs.getUserName will return the user_id of the user. 

you can use

gs.getUserID() == current.getValue('owned_by')

Michael Jones -
Giga Sage

You could try something like this; create an ACL with this condition: 

Created By      is      javascript:gs.getUserName()

Edited: I had getUserID but it should be getUserName for created by.

I hope this helps!

If this was helpful or correct, please be kind and remember to click appropriately!

Michael Jones - Proud member of the CloudPires team!

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

karinmolly
Giga Contributor

Only a professionals in ICT can give a good answer on this topic. Thank you for sharing solutions how to write a user access. I'm a new student at Computer Science and all this things seem to me pretty difficult. But I'm glad I can be a part of ServiceNow community and follow professionals. It's the same as I follow a reliable writing service edubirdie on https://edubirdie.org/  because they have writers in different niches. Already two times they saved me from a failure with research work on servers (I have to admit I'm not so good at it at this moment). Gonna to read more topics here.