- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
We have a requirement to update the reference qualifier for the Configuration Item field on the Incident form using a dictionary override.
How can we implement a reference qualifier so that the field only displays CIs from the cmdb_ci table where:
The "Generic CI" flag (true/false) is set to true,
The CI belongs to the ManagedCI (principal class),
The CI is not in Install Status = Retired, and
All existing CIs in cmdb_ci with names starting with “Generic CI” are automatically flagged as true and included in the filter?
Currently, the existing reference qualifier for the CI field is:
The dictionary override uses:
Given that we cannot modify the TaskUtils script include, how can this requirement be achieved using a dictionary override?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Hi @Pratiksha KC ,
To implement this reference qualifier, you will need to create a new Script Include and then reference it in a Dictionary Override for the cmdb_ci field on the Incident table. Since you cannot modify the existing TaskUtils script include, this approach will avoid conflicts
Sample Script Include:
Name : IncidentCIRefQualifier
var IncidentCIRefQualifier = Class.create(); IncidentCIRefQualifier.prototype = { initialize: function() {}, getRefQual: function(current) { var genericCIs = this.getGenericCIs(); var principalClass = this.getPrincipalClasses(); var retiredStatus = 'Retired'; var encodedQuery = "install_status!=" + retiredStatus; encodedQuery += "^ORgeneric_ci=true"; encodedQuery += "^ORsys_idIN" + genericCIs;
encodedQuery += "^<field_name>IN" + principalClass; return encodedQuery; }, // Helper function to find CIs with names starting with "Generic CI" getGenericCIs: function() { var ciArray = []; var ciGr = new GlideRecord('cmdb_ci'); ciGr.addQuery('name', 'STARTSWITH', 'Generic CI'); ciGr.query(); while (ciGr.next()) { ciArray.push(ciGr.getUniqueValue()); } return ciArray.join(','); }, // Helper function to get CIs from Principal Classes getPrincipalClasses: function() { //write logic to return CI belongs to Managed Cis }, type: 'IncidentCIRefQualifier'};
And In dictionary override, you can use
javascript: new IncidentCIRefQualifier().getRefQual(current);
If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!
Thanks, GP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
you can create your own script include, add filter logic there and then call that in the dictionary override.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
You need to created your own script include and add that in the dictionary override.
The Qualifiers you mentioned looks simple, you can achieve this with GlideRecord with encoded query on cmdb_ci table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Hi @Pratiksha KC ,
To implement this reference qualifier, you will need to create a new Script Include and then reference it in a Dictionary Override for the cmdb_ci field on the Incident table. Since you cannot modify the existing TaskUtils script include, this approach will avoid conflicts
Sample Script Include:
Name : IncidentCIRefQualifier
var IncidentCIRefQualifier = Class.create(); IncidentCIRefQualifier.prototype = { initialize: function() {}, getRefQual: function(current) { var genericCIs = this.getGenericCIs(); var principalClass = this.getPrincipalClasses(); var retiredStatus = 'Retired'; var encodedQuery = "install_status!=" + retiredStatus; encodedQuery += "^ORgeneric_ci=true"; encodedQuery += "^ORsys_idIN" + genericCIs;
encodedQuery += "^<field_name>IN" + principalClass; return encodedQuery; }, // Helper function to find CIs with names starting with "Generic CI" getGenericCIs: function() { var ciArray = []; var ciGr = new GlideRecord('cmdb_ci'); ciGr.addQuery('name', 'STARTSWITH', 'Generic CI'); ciGr.query(); while (ciGr.next()) { ciArray.push(ciGr.getUniqueValue()); } return ciArray.join(','); }, // Helper function to get CIs from Principal Classes getPrincipalClasses: function() { //write logic to return CI belongs to Managed Cis }, type: 'IncidentCIRefQualifier'};
And In dictionary override, you can use
javascript: new IncidentCIRefQualifier().getRefQual(current);
If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!
Thanks, GP