- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2024 09:16 PM
Hi Community,
On incident form, when user selects business service it should show a popup which contains operational status of the business service which user has selected.
Here is my script include.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2024 12:48 AM - edited 02-26-2024 03:02 AM
Hi @Poorva Bhawsar ,
I found few errors in your script please check below,
1. function Callback corrected to callback
2. You were returning ci.operational_status which will not work you have to get the values from script include and then capture it in answer variable
3.In client script closing flower bracket was in wrong place
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ci = g_form.getValue('business_service');
var ga = new GlideAjax('TMUtils');
ga.addParam('sysparm_name', 'getCIStatus');
ga.addParam('sysparm_ci', ci);
ga.getXML(callBack);
}
function callBack(response) {
var answer = response.responseXML.documentElement.getAttribute('answer');
//var userData = answer.split(',');
// alert('The status of this Business Application is: ' + answer[0]);
alert('The status of this Business Application is: ' + answer);
}
in script include dont return the object instead return the value which you want
var TMUtils = Class.create();
TMUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getCIStatus: function() {
var ci = this.getParameter('sysparm_ci');
var gr = new GlideRecord ('cmdb_ci_service');
gr.addQuery('sys_id', ci);
gr.query();
if(gr.next()){
gr.operational_status.getDisplayValue();
}
else{
return '';
}
},
type: 'TMUtils'
});
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2024 02:49 AM
Hi @Poorva Bhawsar in script include could you please try below,
return gr.operational_status.getDisplayValue();
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2024 02:45 AM
Using this also i am getting the backend value of the operational status. I want to show the display name of the operational status in the alert.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2024 02:49 AM
Hi @Poorva Bhawsar in script include could you please try below,
return gr.operational_status.getDisplayValue();
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang