The CreatorCon Call for Content is officially open! Get started here.

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;

 

 

 

8 REPLIES 8

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

LVdV
Tera Expert

Replace 

if (app_obj.next()) {
        return true;
    }
    return false;

by 

return app_obj.hasNext();

It's bit more performant as it only checks if there's a record found and doesn't retrieve it, and a bit more performant can matter when running across all your RITMs.

I want to completely remove GLideRecord from the ACL and only do with something using 

current.request.approvers || current.request.approvers.split(',').indexOf(gs.getUserID()) > -1

@Snehal13 

Did you check my response which I shared above 1hr ago?

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