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:15 PM
Hi @Anubhav24 ,
If the field you are using to show records is reference field so why don't you try to write advance reference qualifier based on public unit and role of current logged in user as query. You can write script include for advance reference qualifier.
Please check and Mark Helpful and Correct if it really helps you.
Regards,
Mayur Shardul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2023 11:26 PM
Hi Mayur , the field is a choice list , small query can I use current.<custom field name>.value == 'Digital' and show only those records using ACL will this work ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2023 11:41 PM - edited 09-24-2023 11:42 PM
Hi @Anubhav24 ,
For ACL it will show other group's user message as some records are restricted due to security constrains, so it will be better to add reference qualifier.
Regards,
Mayur Shardul.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2023 12:19 AM - edited 09-25-2023 12:20 AM
Hi @Anubhav24 ,
Try below script and refence qualifier.
javascript: new testSI().testFunc(current.Public_Unit);
SI :
var getRecords = Class.create();
getRecords.prototype = {
initialize: function() {},
getRec: function(unit) {
var recs = [];
if (unit == 'unitValue' && gs.hasRole('role you required')) {
var userRec = new GlideRecord('table');
userRec.addEncodedQuery('query');
userRec.query();
while (userRec.next()) {
recs.push(userRec.sys_id);
}
}
else if(unit == 'unitValue' && gs.hasRole('role you required')){
userRec = new GlideRecord('table');
userRec.addEncodedQuery('query');
userRec.query();
while (userRec.next()) {
recs.push(userRec.sys_id);
}
}
return 'sys_idIN' + recs;
},
type: 'getRecords'
};
Regards,
Mayur