The Zurich release has arrived! Interested in new features and functionalities? Click here for more

ACL based on field values

Anubhav24
Mega Sage
Mega Sage

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.

 

11 REPLIES 11

Vishal Birajdar
Giga Sage

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);
 
 
Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

Hi @Vishal Birajdar ,

 

What would be the script logic in ACL current.<field name>.value == 'Digital' / 'Cloud'?

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.

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

Ankur Bawiskar
Tera Patron
Tera Patron

@Anubhav24 

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar ,

 

What would be the script logic in ACL current.<field name>.value == 'Digital' / 'Cloud'?