Script Include returning null?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 12:11 AM
Hi all,
The following Script returning null value. I need consumer sys_id. Thanks in advance
Script Include -
var customerPhones = Class.create();
customerPhones.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
ConsumerS: function() {
var g = this.getParameter('syparm_cons');
var CONsumer = '';
gs.info("Include::::" + g);
var gr1 = new GlideRecord('sn_customerservice_product_service_support');
gr1.addQuery('sys_id', g);
gr1.query();
if (gr1.next()) {
CONsumer = gr1.consumer;
}
return CONsumer;
},
Client Script -
var ans = '';
var con = g_form.getValue('parent');
var ga1 = new GlideAjax('sn_customerservice.customerPhones');
ga1.addParam('syparm_name', 'ConsumerS');
ga1.addParam('syparm_cons', con);
ga1.getXML(HelloWorld);
function HelloWorld(response) {
ans = response.responseXML.documentElement.getAttribute("answer");
alert(ans);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 12:18 AM
Hi,
Try to add more logs statement in script include and check what ir prints in system logs.
var customerPhones = Class.create();
customerPhones.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
ConsumerS: function() {
var g = this.getParameter('syparm_cons');
var CONsumer = '';
gs.info("Include::::" + g);
var gr1 = new GlideRecord('sn_customerservice_product_service_support');
gr1.addQuery('sys_id', g);
gs.info("Include row count::::" + gr1.getRowCount());
gr1.query();
if (gr1.next()) {
CONsumer = gr1.consumer;
}
gs.info("CONsumer " + CONsumer);
return CONsumer;
},
Thanks,
Sagar Pagar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 12:20 AM
Hi
Change your script as below:
Make sure your script include has "Accessible from" field as "All application scope"
Script Include -
var customerPhones = Class.create();
customerPhones.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
ConsumerS: function() {
var g = this.getParameter('sysparm_cons');
var Csumer = '';
gs.info("Include::::" + g);
var gr1 = new GlideRecord('sn_customerservice_product_service_support');
gr1.addQuery('sys_id', g);
gr1.query();
if (gr1.next()) {
csumer = gr1.getValue("consumer");;
}
return csumer;
},
Client Script -
var ans = '';
var con = g_form.getValue('parent');
var ga1 = new GlideAjax('sn_customerservice.customerPhones');
ga1.addParam('sysparm_name', 'ConsumerS');
ga1.addParam('sysparm_cons', con);
ga1.getXML(HelloWorld);
function HelloWorld(response) {
ans = response.responseXML.documentElement.getAttribute("answer");
alert(ans);
}
Feel free to mark correct, if your issue has been resolved, so it ends up in solved queue.
Will be helpful for others looking for the similar query.
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 12:34 AM
Hi,
Is script include client callable?
Script include and client script are in same scope?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 12:41 AM
Yes client callable