Auto Reject approval script (Add exceptions)

Nikita50
Tera Expert

Per current setup all the requests are auto rejected with 8 days except for one group lets name is A.

Script is already in place of it.

New requirement is to set exception for three group, lets name them A,B,C

 

How to update existing script to add B, C also.

 

Current script:

var ca = new GlideRecord('sysapproval_approver');
ca.addQuery('state''requested');
ca.addQuery('sys_created_on''<', gs.daysAgo(8));
    //Update: Adding condition 
var cancelOR = ca.addQuery('group.assignment_group.name''!=''A');
cancelOR.addOrCondition('group''');
1 REPLY 1

Connor Levien
ServiceNow Employee
ServiceNow Employee

I would suggest to read up on the gliderecord query capability a quick google can show you how to do this but for reference you would do something like the flowing

var exemptGroups = ['A', 'B', 'C'];
ca.addEncodedQuery("sys_idNOT IN"+exemptGroups);

 

Refer to this guide as well that a community member has made that is helpful 

https://www.servicenow.com/community/developer-articles/how-to-use-is-not-one-of-filter-condition-on...

 

Hope that helps!