ACL based on field values
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2023 10:51 PM
Hi All,
I have fields on my custom table and there is one field for Public Unit and there are drop down values in this field like 'Digital' , 'Cloud' etc. , my ask is to show records to user based on the values selected in this field.
Ex : Show 'Digital' records to Workflow team and show 'Cloud' records to Cloud team.
Can I write ACLs based on the value selected using the current object , is this possible because mostly I have configured ACLs based off of roles only.
Do I need to go write the query business rule and what would be the best option if writing ACL is possible.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2023 11:25 PM - edited 09-24-2023 11:26 PM
Hi @Anubhav24
ACL will be the best option but If its only to show the records for particular groups then you can try with "Before query".
(function executeRule(current, previous /*null when async*/ ) {
showRecords();
function showRecords() {
if (gs.getUser().isMemberOf("Workflow group name")) {
current.addEncodedQuery('u_public_unit=Digital'); //put your query
} else if (gs.getUser().isMemberOf("Cloud team group name")) {
current.addEncodedQuery("u_public_unit=Cloud");
} else {
//put your query if not user is not member of above groups
}
}
})(current,previous);
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2023 12:01 AM
Hi @Vishal Birajdar ,
What would be the script logic in ACL current.<field name>.value == 'Digital' / 'Cloud'?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2023 01:08 AM
Hi @Anubhav24
For ACL, you would need to create separate ACL record for each choice, while creating ACL you will get the condition field where you can select "Public unit" is "Digital" like this.
But It will be better if you go with query BR.
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2023 11:51 PM
You should use query business rule here.
If you want to use ACLs then you will require 2 table level READ ACLs 1 for each choice value
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2023 12:01 AM
Hi @Ankur Bawiskar ,
What would be the script logic in ACL current.<field name>.value == 'Digital' / 'Cloud'?