Regarding service_offering table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2023 09:45 AM
Hi All
I have query regarding service_offering table.
Based on the service_classification field parent reference values need to show.
For example service_classification is technical service then technical service related records needs to show in parent reference field. And service_classification is business service then Business service related records needs to show in parent reference field.
Parent table is reference from cmdb_ci_service table.
Please let me know how to achieve this using reference qualifier.
Thanks & Regards,
Madhu.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2023 05:50 AM
Open the service_offering table definition.
Find the parent field (which is a reference field).
Configure the reference qualifier script for the parent field.
The reference qualifier script can be written in JavaScript and should be based on the value of the service_classification field. Here's a sample script that demonstrates the logic you described:
(function() {
// Get the current value of the 'service_classification' field
var serviceClassification = current.service_classification;
// Create a new GlideRecord object for the 'cmdb_ci_service' table
var parentGR = new GlideRecord('cmdb_ci_service');
// Check the value of 'service_classification' and set the appropriate query
if (serviceClassification == 'technical service') {
parentGR.addQuery('classification', 'technical');
} else if (serviceClassification == 'business service') {
parentGR.addQuery('classification', 'business');
}
// Execute the query and set the reference qualifier
parentGR.query();
current.parent.setRefQual('sys_idIN' + getSysIds(parentGR));
// Function to get a comma-separated list of sys_ids from a GlideRecord
function getSysIds(gr) {
var sysIds = [];
while (gr.next()) {
sysIds.push(gr.sys_id);
}
return sysIds.join(',');
}
})();