Add more criteria to encoded query
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2024 11:10 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2024 02:19 PM - edited 10-17-2024 02:20 PM
You're not even seeing the SI Running log - even if you change it to gs.info...? Make sure you don't have any other Script Includes with this same name, and that your script include name and function are exactly what you are using in the reference qualifier like my examples. I'm not following the part about changing the parent - did you change the system property value? Is the Script Include in the same scope as the Catalog Item and reference variable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2024 06:44 AM
Hello Brad,
I am seeing below it is making it into function but not loop.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2024 06:59 AM
That likely means that no records are returned that match 'qry'. We can confirm that with more logs, along with the system property values so you can make sure those values are pulled into the query, and the values will help troubleshoot how to tweak the qry to what you want based on the manual procedure I described earlier.
var AssignmentGroupMaintenanceAjax = Class.create();
AssignmentGroupMaintenanceAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, {
groupExclusion: function() {
gs.info('SI running')
var groupSysIDs = [];
var parentProp = gs.getProperty("servicenow.parent.groups");
gs.info('SI parentProp= ' + parentProp);
var exProp = gs.getProperty("groups.to.exclude");
gs.info('SI exProp= ' + exProp);
var qry = 'nameIN' + parentProp + '^sys_idIN' + exProp + '^typeNOT LIKE7a5370019f22120047a2d126c42e705c^parent!=904c25b01b00525c62cb2139b04bcb34';
var groupGr = new GlideRecord('sys_user_group');
groupGr.addEncodedQuery(qry);
groupGr.query();
if (!groupGR.hasNext()) {
gs.info('SI no records found');
}
while (groupGr.next()) {
gs.info('SI group excluded: ' + groupGr.name)
groupSysIDs.push(groupGr.sys_id.toString());
}
return groupSysIDs.join(',');
},
type: 'AssignmentGroupMaintenanceAjax'
});
Share the logs if you're still stuck.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2024 08:32 AM
Hello Brad,
I changed the query to exclude all parent group of all hr groups but still not filtering. The only log appearing is the SI Running.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2024 09:50 AM
Everything I said in my last reply still applies and will get to the bottom of the issue.