guru4
Kilo Guru

Hi @abjaffrey 

In script include line number 7 you mistakenly used 

"callersRecord", it should be "callersRecords" you have missed the 's' which you have declared as variable :var callersRecords = new GlideRecord('incident'); Please make the changes it should work fine.
Mark my answer as correct and helpful if it solves your query

View solution in original post

Hey @guru4 

 

Thanks for the response, it worked.

 

Can you help why when i passed as JSON initially (if you see i initially wanted multiple return values as key value pairs in an array) i was unable to find the desired result.

View solution in original post

function onLoad() {
//Type appropriate comment here, and begin script below

 

//g_form.addInfoMessage('hello');
var incGA = new GlideAjax('CallerIncidents');
incGA.addParam('sysparm_name', 'getCallersIncs');
incGA.addParam('sysparm_callerID', g_form.getValue('caller_id'));
incGA.getXMLAnswer(CallerIncidentsParse);

 

function CallerIncidentsParse(response) {
var myObj = JSON.parse(response);
g_form.addInfoMessage('User has raised the following incidents:');

 

for (var i=0; i< myObj.length; i++) {
g_form.addInfoMessage(myObj[i]);
}
}
}
Just use g_form.addInfoMessage(myObj[i]); instead of g_form.addInfoMessage(myObj[i].number); Since that object only contains number inside it no need to mention it separately.
Mark my answer as correct and helpful if it solves your query
Regards,
Guru

View solution in original post

hi

 

thanks for the response

Rohit99
Mega Sage

Hi @abjaffrey ,

Please correct the following line:

callersRecord.addQuery('caller_id'this.getParameter('sysparm_callerID'));

as,

callersRecords.addQuery('caller_id'this.getParameter('sysparm_callerID'));

character 's' is missing in the end of callersRecords word.