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.

Business rule gliderecord

eyal abu hamad
Mega Sage

Hi all,
I have business rule with simple glide record script.

if I entering the business rule via system administrator it will work fine.

but if I entered the business rule while impersonating another user that have ( itil , snc_internal and public_auction_admin) roles it well not enter the Glide Record.

(function executeRule(current, previous /*null when async*/ ) {

    if (gs.getSession().getUser().hasRole('public_auction_admin')) {
        var gr = new GlideRecord('sc_task');
        gr.addQuery('request_item', current.sys_id);
        gr.addEncodedQuery('stateNOT IN3,4,7');
        gr.query();
        while (gr.next()) {
				gr.state = 2;
                gr.update();
        }
    }


})(current, previous);

 as I mentioned before, the business rule work only for administrator 

2 REPLIES 2

Anand Kumar P
Giga Patron

Hi @eyal abu hamad ,
If the current user has the role 'public_auction_admin'. If the user has this role, the condition evaluates to true, and the code block within the if statement will be executed. If the user does not have the 'public_auction_admin' role, the code block will be skipped.
Also Check the acl on sc_task table and have read access to itil , snc_internal and public_auction_admin roles and also user have table level access to read or write .
Glide Record query, you are querying 'sc_task' records based on the 'request_item' field, so it's important to check the security settings on the 'request_item' field and its associated table to ensure that users with the roles

AnandKumarP_0-1699522599849.png

Please mark it as helpful and solution proposed if its serves your purpose.

Thanks,

Anand

 

 

 

eyalabuhamad_0-1699523378675.png

I added all the roles and created also read and also write ACL record but still same thing