- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 08:09 AM
Hi Friends,
I have a requirement that is, on incident form if I change the "category" field to 'Applications' then the lookup table for the "Configuration Item" reference field should be change to "Business Applications" table.
Info: Category is choice field
Configuration Item is Reference field.
Waiting for some suggestions!!
Thanks,
Vasanth
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 12:32 PM
The Dictionary Entry data, such as the Reference table on a Reference type field, cannot be changed by a UI action or script to preserve data integrity - it can only be done on the Dictionary Entry form itself. In this case it doesn't sound like that's really what you want to do, rather alter the reference qualifier. First we need to determine what the reference qualifier is in your environment, so right-click on the Configuration item field label on the incident form and choose Configure Dictionary. Note on the Dictionary Entry form that this field, with the Column name cmdb_ci is actually on the Task table and it is referencing the Base Configuration Item table (cmdb_ci). This is important because "Business Applications" is extended from and included in the cmdb_ci table, so all you really want to do is filter the list of records to only show sys_class_name=cmdb_ci_business_app when the "Applications" category is selected.
Since the incident table is extended from the Task table, all of the columns on the task table are available to the Incident, and other extended tables. This is important in that when you're looking to see what the existing reference qualifier is, you're not going to want to look on the Reference Specification tab as you normally would for a reference field, rather you need to look further down on the Dictionary Entry to the Dictionary Overrides Related List. On this Related List look for an existing entry for the incident table, or create one if it doesn't exist. A Dictionary Override ensures that anything you change only applies to that specific table, not the base table and all of the other tables that are extended from it! On the Dictionary Entry Override for this column and the incident table, Override reference qualifier should be checked. The Reference qualifier noted here is what is actually controlling what you see on the incident form. Mine, which I believe is out of box, look like this:
This tells me that the list of records is being determined in a Script Include name TaskUtils and a function inside that Script Include named getConfigurationItemFilter, passing in the entire current incident record for potential use in the function. The TaskUtils Script Include is a placeholder for customizations to the out of box TaskUtilsSNC Script Include which cannot be altered. If this is the reference qualifier you have for the incident table override, take a look at the TaskUtilsSNC Script Include so you can see what it's doing. The getConfigurationItemFilter function starting on line 263 is basically excluding CIs with the class of service_offering and some invalid operational_status values. If the CIs/records/Business Applications that you are looking for already appear in the Configuration item list, it's just that you want ONLY these to appear when the "Applications" category is selected, then you don't have to worry about/change what these scripts are already doing.
To change the reference qualifier, you can change the TaskUtils Script Include to override the SNC version, but I've never actually done this so you'll have to look elsewhere for an example. We have always just created a new Script Include that does what we want it to, then call that in the reference qualifier dictionary override, which looks like this:
The getCi function in this case would look similar to this:
getCi: function(cat) { //This function returns the CIs related to the selected Category
var ciRefQual = 'sys_class_nameINjavascript:new PrincipalClass().getPrincipalClasses()^install_status!=7^nameISNOTEMPTY'; //this line mimics the SNC script
if (cat == 'Applications') { //ensure this is the correct VALUE for this choice record
var getCiResults = [];
var gr = new GlideRecord('cmdb_ci');
gr.addQuery('sys_class_name', 'cmdb_ci_business_app');
gr.query();
while (gr.next()) {
getCiResults.push(gr.sys_id.toString());
}
getCiResults = ciRefQual + "^sys_idIN" + getCiResults.join(',');
return getCiResults;
} else {
return ciRefQual;
}
},
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 12:32 PM
The Dictionary Entry data, such as the Reference table on a Reference type field, cannot be changed by a UI action or script to preserve data integrity - it can only be done on the Dictionary Entry form itself. In this case it doesn't sound like that's really what you want to do, rather alter the reference qualifier. First we need to determine what the reference qualifier is in your environment, so right-click on the Configuration item field label on the incident form and choose Configure Dictionary. Note on the Dictionary Entry form that this field, with the Column name cmdb_ci is actually on the Task table and it is referencing the Base Configuration Item table (cmdb_ci). This is important because "Business Applications" is extended from and included in the cmdb_ci table, so all you really want to do is filter the list of records to only show sys_class_name=cmdb_ci_business_app when the "Applications" category is selected.
Since the incident table is extended from the Task table, all of the columns on the task table are available to the Incident, and other extended tables. This is important in that when you're looking to see what the existing reference qualifier is, you're not going to want to look on the Reference Specification tab as you normally would for a reference field, rather you need to look further down on the Dictionary Entry to the Dictionary Overrides Related List. On this Related List look for an existing entry for the incident table, or create one if it doesn't exist. A Dictionary Override ensures that anything you change only applies to that specific table, not the base table and all of the other tables that are extended from it! On the Dictionary Entry Override for this column and the incident table, Override reference qualifier should be checked. The Reference qualifier noted here is what is actually controlling what you see on the incident form. Mine, which I believe is out of box, look like this:
This tells me that the list of records is being determined in a Script Include name TaskUtils and a function inside that Script Include named getConfigurationItemFilter, passing in the entire current incident record for potential use in the function. The TaskUtils Script Include is a placeholder for customizations to the out of box TaskUtilsSNC Script Include which cannot be altered. If this is the reference qualifier you have for the incident table override, take a look at the TaskUtilsSNC Script Include so you can see what it's doing. The getConfigurationItemFilter function starting on line 263 is basically excluding CIs with the class of service_offering and some invalid operational_status values. If the CIs/records/Business Applications that you are looking for already appear in the Configuration item list, it's just that you want ONLY these to appear when the "Applications" category is selected, then you don't have to worry about/change what these scripts are already doing.
To change the reference qualifier, you can change the TaskUtils Script Include to override the SNC version, but I've never actually done this so you'll have to look elsewhere for an example. We have always just created a new Script Include that does what we want it to, then call that in the reference qualifier dictionary override, which looks like this:
The getCi function in this case would look similar to this:
getCi: function(cat) { //This function returns the CIs related to the selected Category
var ciRefQual = 'sys_class_nameINjavascript:new PrincipalClass().getPrincipalClasses()^install_status!=7^nameISNOTEMPTY'; //this line mimics the SNC script
if (cat == 'Applications') { //ensure this is the correct VALUE for this choice record
var getCiResults = [];
var gr = new GlideRecord('cmdb_ci');
gr.addQuery('sys_class_name', 'cmdb_ci_business_app');
gr.query();
while (gr.next()) {
getCiResults.push(gr.sys_id.toString());
}
getCiResults = ciRefQual + "^sys_idIN" + getCiResults.join(',');
return getCiResults;
} else {
return ciRefQual;
}
},
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 10:32 AM
Hi @Brad Bowman ,
I am very much thankful to your solution. Because I learnt a new thing however, by following your solution I am getting no records in "configuration item" filed even the category is not "Applications".
I don't know why I am getting the empty list. Please take me forward. Because I guess I am close to the solution.
Thanks & Regards,
Vasanth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 10:38 AM
Wherever this site text editor puts javascript: replace that with javascript then the colon symbol. If it's still not working, post your entire Script Include - making sure the Client callable box is checked and that the name of the Script Include is unique.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 11:07 AM - edited 09-01-2023 11:40 AM
Still I am getting empty records. Please see the attached captures. And also for the sake of flexibility I am pasting my script include here.