- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2023 07:38 AM
Hi Team,
I would really appreciate any help/guidance on how to achieve/modify the script I have, to achieve this.
On my Incident form I have a field for Service (business_service) and Business Application (u_business_application).
I want to put a Reference Qualifier on the Service (business_service) field, so that when Business Application is populated, the only options that show in the Service field are children of the parent Business Application.
I currently have the following script include and reference qualifier, which can be used to achieve the same, for showing CI's that relate to a service offering, but how can I amend this script include and the related reference qualifier javascript, so that I can achieve a similar process for only showing Service related to the Business Application.
Here is the Reference Qualifier Javascript I need to modify:
javascript: new IncidentUtils().getCis(current.service_offering);
And Here is associated script include I am wanting to modify:
var IncidentUtils = Class.create();
IncidentUtils.prototype = {
getCis: function(so) {
var getCiArr = [];
if (so) {
var cm = new GlideRecord('cmdb_ci');
cm.addEncodedQuery('sys_class_name=service_offering');
cm.addQuery('sys_id', so);
cm.query();
if (cm.next()) {
var gr = new GlideRecord('cmdb_rel_ci');
gr.addQuery('parent', cm.sys_id);
gr.query();
while (gr.next()) {
getCiArr.push(gr.child.sys_id.toString());
}
return "sys_idIN" + getCiArr.join(',');
}
}
},
type: 'IncidentUtils'
};
Thanks very much - any help/guidance, very much appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2023 01:01 PM
Reference qualifier for Service field dictionary: Replace "u_business_application" field with your business application field name if its different
javascript: new IncidentUtils().getServiceList(current.u_business_application);
Add below code in "IncidentUtils" script include
getServiceList: function(business_application) {
var getServices = [];
if (business_application) {
var grCIRelationsip = new GlideRecord('cmdb_rel_ci');
grCIRelationsip.addQuery('parent.sys_class_name=cmdb_ci_business_app');
grCIRelationsip.addQuery('parent', business_application);
grCIRelationsip.query();
while (grCIRelationsip.next()) {
getServices.push(grCIRelationsip.getValue('child'));
}
return "sys_idIN" + getServices.join(',');
}
},
I tested this script include in PDI & its working
If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !! This will help others as well 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2023 01:01 PM
Reference qualifier for Service field dictionary: Replace "u_business_application" field with your business application field name if its different
javascript: new IncidentUtils().getServiceList(current.u_business_application);
Add below code in "IncidentUtils" script include
getServiceList: function(business_application) {
var getServices = [];
if (business_application) {
var grCIRelationsip = new GlideRecord('cmdb_rel_ci');
grCIRelationsip.addQuery('parent.sys_class_name=cmdb_ci_business_app');
grCIRelationsip.addQuery('parent', business_application);
grCIRelationsip.query();
while (grCIRelationsip.next()) {
getServices.push(grCIRelationsip.getValue('child'));
}
return "sys_idIN" + getServices.join(',');
}
},
I tested this script include in PDI & its working
If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !! This will help others as well 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2023 01:12 PM
Hello Anvesh,
This works perfectly !!
I have it all up and running now on my PDI - thank you very much I really appreciate your help, knowledge and expertise Anvesh.
Thanks ever so much, have a great day 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 04:08 AM - edited 07-24-2023 04:13 AM
Hello Anvesh,
How can I / what would be the Script Include and related Reference Qualifier to exactly reverse this logic?
So exact same process, but I want the Business Application to be dependant on the Service. (so the Business Application is a Child of the Service - which is the Parent).
So the Reference Qualifier would be placed on the 'Business Application' field and it would be the 'Business Applications' that are reference qualified, after the 'Service' has been selected?
So it is basically a reverse of the logic/script we have discussed above.
I would appreciate your guidance with the amended Reference Qualifier javascript and amended Script Include, for this scenario.
Many thanks.