When category and Location select dependent CI appear
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago - last edited 3 hours ago
This is all for change_request
I have created client scripts for Category and Location to display dependent CIs. My requirement is that when both Category and Location are selected, the CI should appear accordingly. However, the CI Class is showing the same value and not changing based on the selected Category.
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Try this:
1 Create a Script Include
Name: DependentCIs
- Client Callable: true
var DependentCIs = Class.create();
DependentCIs.prototype = {
initialize: function() {},
getFilteredCIs: function(category, location) {
var ciArray = [];
var gr = new GlideRecord('cmdb_ci');
if (category) {
gr.addQuery('category', category);
}
if (location) {
gr.addQuery('location', location);
}
gr.query();
while (gr.next()) {
ciArray.push(gr.getUniqueValue());
}
return 'sys_idIN' + ciArray.join(',');
},
type: 'DependentCIs'
};
2.
- Open a Change Request form.
- Right-click the Configuration item (cmdb_ci) field label and select Configure Dictionary.
- Scroll down to the Dictionary Overrides related list and click New.
- Select the Table as change_request.
- Check the Override reference qualifier box.
- In the Reference qual field, enter the following JavaScript to pass the form's fields to your Script Include:
- javascript: new DependentCIs().getFilteredCIs(current.category, current.location);
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
2 hours ago