Need to return multiple value from Script incldue to client script

nkumari
Tera Contributor

Script include to return CI number and support group manager name. But it is not returning value

 

var applicationIDPopulation = Class.create();
applicationIDPopulation.prototype = Object.extendsObject(AbstractAjaxProcessor, {

getApplicationDetails: function() {

var application_name = this.getParameter('sysparm_id');
var result;
var grApplication = new GlideRecord('cmdb_ci_service_discovered');
grApplication.addQuery('sys_id', application_name);
grApplication.query();

if (grApplication.next()) {

var appobje = {};
appobje.num = grApplication.u_business_app.u_number.toString();
appobje.senmanger = grApplication.support_group.u_senior_manager.toString();
}
return JSON.Stringfy(appobje);

},

type: 'applicationIDPopulation'
});

 

Client Script:

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}

//Type appropriate comment here, and begin script below
var ga = new GlideAjax('applicationIDPopulation');
ga.addParam("sysparm_name", "getApplicationDetails");
ga.addParam("sysparm_id", g_form.getValue('application_id'));
ga.getXML(getResponse);
function getResponse(response) {

var answer = response.responseXML.documentElement.getAttribute('answer');

var result = JSON.parse(answer);


g_form.addInfoMessage( g_form.getValue('application_id'));

g_form.setValue('populate_application_id', result.num);
g_form.setValue('u_level_approval', result.senmanger);

}
}

1 ACCEPTED SOLUTION

Namrata Ghorpad
Mega Sage
Mega Sage

Hello In script include inside if change the code like below

if (grApplication.next()) {

var appobje = {};
appobje.num = grApplication.u_business_app.u_number.toString();
appobje.senmanger = grApplication.support_group.u_senior_manager.toString();
return JSON.stringfy(appobje);
}


},

 Regards,

Namrata 

View solution in original post

5 REPLIES 5

Anil Lande
Kilo Patron

@nkumari Glad to know your issue is resolve, I believe I had provided the correct solution with explanation first. Hope you found the mistake in your script. Happy Learning!

Note- You can mark more than one response as correct answer.

 

  

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande