Issue with Dynamic Filter Option
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
1. For many dynamic filter configurations, the Script Include must be marked as Client Callable to be accessible by the filter engine . You ensure the same.
2. call
From: new global. SoxUtils().getSoxRelatedCis()
To: (new SoxUtils()).getSoxRelatedCis()
3. In script include ,
instead of
return 'sys_idIN' + unique.join(',');
Use
return unique.toString()
And then call by new global. SoxUtils().getSoxRelatedCis()
4. Line 33 , I have never tried, just before ,after put log and check what your getting.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi Tanushree,
I have implemented their changes, still not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hi @ArpitB207098286 ,
Make sure to set "Sandbox enabled" to TRUE on your script include.
Test it from a background script first to make sure the sys_id's are being returned correctly from the script include.
Also, as @Tanushree Maiti mentioned, remove the 'sys_idIN' part when returning from script include.
Let me know if this works,
Marius
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hello @ArpitB207098286
Script Include:
var SoxUtils = Class.create();
SoxUtils.prototype = {
initialize: function() {},
getSoxRelatedCIs: function() {
var result = [];
var sox = new GlideRecord('cmdb_ci');
sox.addQuery('name', 'SOX - Sarbanes-Oxley');
sox.query();
if (sox.next()) {
var rel = new GlideRecord('cmdb_rel_ci');
rel.addQuery('child', sox.sys_id);
rel.query();
while (rel.next()) {
var parentId = rel.parent.toString();
if (result.indexOf(parentId) === -1) {
result.push(parentId);
}
}
}
return result;
},
type: 'SoxUtils'
};
Dynamic Filter Options:
Validation Results:
Configuration Item:
CI Relationships:
Incident List View:
Background Script: Always recommened to validate code in background script first and then use it later in actual server-side or client-side script.
Hope that helps!