- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2024 08:04 AM
Hello All,
I want to show an info message on incident onload of any ongoing outage. I wrote a client script and script include. But it is showing eeror.
Script include:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2024 08:34 AM
Hi @I_Das ,
I tried your problem in my PDI and I hope this will work you!
Please change your Client Script code with below script
function onLoad() {
//Type appropriate comment here, and begin script below
var ga = new GlideAjax('OutageScriptInclude');
ga.addParam('sysparm_name', 'Outage');
ga.addParam('sysparm_buildingid', g_form.getValue('number'));
ga.getXML(getResHandler);
function getResHandler(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
var clearvalue; // Stays Undefined
if (answer) {
alert('test');
}
}
}
Script Include : Which is client callable
var OutageScriptInclude = Class.create();
OutageScriptInclude.prototype = Object.extendsObject(AbstractAjaxProcessor, {
Outage: function() {
gs.log('Inside OutageScriptInclude ');
var num = this.getParameter('sysparm_buildingid');
var outageGr = new GlideRecord('cmdb_ci_outage');
outageGr.addQuery('begin', '<', new GlideDateTime());
outageGr.addQuery('end', '=', 'NULL');
outageGr.query();
if (outageGr.hasNext()) {
gs.log('Isnide IF OutageScriptInclude');
return true;
}
},
type: 'OutageScriptInclude'
});
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2024 08:17 AM
Hi @I_Das,
You need to use the Client callable script include with GlideAjax call instead of direct calling Script include in Client strips.
Take a reference of nice article written by @Shawn Dowler
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2024 08:32 AM
Hello @Sagar Pagar ,
I have modified the client script as:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2024 08:34 AM
Hi @I_Das ,
I tried your problem in my PDI and I hope this will work you!
Please change your Client Script code with below script
function onLoad() {
//Type appropriate comment here, and begin script below
var ga = new GlideAjax('OutageScriptInclude');
ga.addParam('sysparm_name', 'Outage');
ga.addParam('sysparm_buildingid', g_form.getValue('number'));
ga.getXML(getResHandler);
function getResHandler(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
var clearvalue; // Stays Undefined
if (answer) {
alert('test');
}
}
}
Script Include : Which is client callable
var OutageScriptInclude = Class.create();
OutageScriptInclude.prototype = Object.extendsObject(AbstractAjaxProcessor, {
Outage: function() {
gs.log('Inside OutageScriptInclude ');
var num = this.getParameter('sysparm_buildingid');
var outageGr = new GlideRecord('cmdb_ci_outage');
outageGr.addQuery('begin', '<', new GlideDateTime());
outageGr.addQuery('end', '=', 'NULL');
outageGr.query();
if (outageGr.hasNext()) {
gs.log('Isnide IF OutageScriptInclude');
return true;
}
},
type: 'OutageScriptInclude'
});
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2024 09:06 AM
Hello @Community Alums ,
It worked. Thank you very much.
Thanks & Regards,
I**bleep**a Das