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.

Add more criteria to encoded query

purdue
Kilo Sage

Hello,

I need to exclude HR groups to this query please assist.

Thanks,

Chad

Add exclusion of HR Groups Type is Human Resources and Parent is not HRSD.

typeNOT LIKE7a5370019f22120047a2d126c42e705c^parent!=904c25b01b00525c62cb2139b04bcb34

 

To

groupsExclusion: function() {
var groupSysIDs = [];
query = 'sys_idIN' + gs.getProperty("groups.to.exclude");
var group = new GlideRecord('sys_user_group');
group.addEncodedQuery(query);
group.query();
while (group.next()) {
groupSysIDs.push(group.sys_id + "");
}
return groupSysIDs;
},
17 REPLIES 17

Hey @Brad Bowman  @purdue 

I’ve been following your discussion and I think I might have caught something interesting here.

It looks like you guys are using a client-callable Script Include (with the AJAX suffix and extending AbstractAjaxProcessor), which won't work when called within the Reference Qualifier.

 

If that’s the case, let's try creating a new Script Include without enabling client-callable, and give it another go.

 

Cheers,
Tai Vu

Thanks for the suggestion, but this is a simple case of GlideRecord query criteria not retrieving any records, which will be made clear with logging.  While it is not necessary to make a Script Include Client callable, extending the AbstractAjaxProcessor, when used only in a reference qualifier, doing so will not stop the script from working - such as the reverse case: calling a Script Include from a Client Script with GlideAjax, will not work unless the AbstractAjaxProcessor is extended.  In this way a Script Include, and even the same function, can be used both in calls from reference qualifiers/business rules/UI Actions/... AND Client Scripts.

purdue
Kilo Sage

Hello Brad,

Wanted to follow up waiting for the BA to confirm exactly what they want to exclude.   I assumed it was all HR groups but BA was not sure.  Will keep you posted.  Thanks again for all your help.

Chad