02-13-2019 07:15 PM
Hi Team,
I am developing a custom application in my personal dev instance. I am trying to invoke script include in client script and while doing I am facing AbstractAjaxProcessor error. I have verified API name to match in both the scripts and to call right function name.
Client Script
function onSubmit(){
if (g_form.getValue('first_name') == '' || g_form.getValue('last_name') == ''){
g_form.addErrorMessage('First and Last name cannot be empty!');
return false;
}
var ga = new GlideAjax('SZAPICall');
ga.addParam('sysparm_name','loadData');
ga.addParam('sysparm_first_name',g_form.getValue('first_name'));
ga.addParam('sysparm_last_name',g_form.getValue('last_name'));
alert('before getXML');
ga.getXML(JSONParse);
alert('after getXML');
function JSONParse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
}
}
Scirpt Include
var SZAPICall= Class.create();
SZAPICall.prototype = Object.extendsObject(AbstractAjaxProcessor,{
loadData:function(){
alert('inside script include');
return this.getParameter('sysparm_first_name')+"|"+this.getParameter('sysparm_last_name');
},
type: 'SZAPICall',
isPublic: true
});
I am getting below error upon form submission
Can someone please let me know what is going wrong in this approach?
Thanks
Solved! Go to Solution.
02-13-2019 07:21 PM
You are missing a "global" prefix.
When extending a global Script Include from a Scoped Script, you must prefix with global.
SZAPICall.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
02-13-2019 07:21 PM
You are missing a "global" prefix.
When extending a global Script Include from a Scoped Script, you must prefix with global.
SZAPICall.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
02-13-2019 07:33 PM
Thanks Paul, I didn't know about this. This fixed the error, however loadData function is not called. Is there a different way to call this function from scoped to global script?
02-13-2019 07:36 PM
You don't need alert in script include (server side code).
alert('inside script include');
02-13-2019 07:38 PM
True, I have removed it and now I see the script include code got executed. Thanks guys!