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.

How to Avoid GlideRecord in ACL

Snehal13
Kilo Sage

I have an ACL on sc_req_item table as below to allow read access to the RITM for sc task approvers.

How to remove GlideRecord usage in ACL and replace with ACL conditions so that it still grants read access to the RITM and variables on it for sc task approvers

 

 

 

    var app_obj = new GlideRecord('sysapproval_approver');
    app_obj.addQuery('approver', gs.getUserID());
    app_obj.addQuery('sysapproval', current.sys_id);
    app_obj.query();
    if (app_obj.next()) {
        return true;
    }
    return false;

 

 

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Snehal13 

not possible directly using condition as RITM table doesn't hold approver info

You can move code to Script include and call that in ACL script and you should be good.

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

9 REPLIES 9

I did but the ask is not to move to script include and only way left is to do with ACL conditions

@Snehal13 

then not possible directly.

Use this approach

1) create custom field of type List referring to sys_user

2) store the approvers of that RITM in it

3) then use this in ACL condition

AnkurBawiskar_0-1759932420434.png

 

💡 If my response helped, please mark it as correct ✔️ and close the thread 🔒 — this helps future readers find the solution faster! 🙏

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

@Snehal13 

Hope you are doing good.

Did my reply answer your question?

💡 If my response helped, please mark it as correct ✔️ and close the thread 🔒 — this helps future readers find the solution faster! 🙏

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

@Snehal13 what is datatype of ?

current.request.approvers

you can verify with below code.

(function() {
answer = false;

// Ensure we have a parent request and an approvers list
if (current.request && current.request.approvers) {
var approvers = current.request.approvers + ''; // force to string
if (approvers.split(',').indexOf(gs.getUserID()) > -1) {
answer = true;
}
}
})();

tried but didnt work