Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Exam name is not getting displayed

avinashdubey103
Tera Guru

Hi , I have written a on change client script to set the  certification vendor name and exam name  on the change of u_license_request ,
But the exam name is not getting set  , the certification vendor is getting set :

On change client script :

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
g_form.setValue('u_certification_vendor_name','');
g_form.setValue('u_exam_name1','');
return;
}
 
if(newValue!=oldValue){
g_form.setValue('u_certification_vendor_name','');
g_form.setValue('u_exam_name1','');
 
 
var LCR=newValue;
 
var ga = new GlideAjax('global.ld_ajax_helper'); 
ga.addParam('sysparm_name','getVendorNExam'); 
ga.addParam('sysparm_lcr',LCR);
 
ga.getXMLAnswer(VendorExamParse); 
}
}
 
// callback function for returning the result from the script include
function VendorExamParse(response) {  
 
var res=JSON.parse(response);
var jsonstring1=JSON.stringify(res);
console.log("res"+jsonstring1);
 
g_form.setValue('u_certification_vendor_name',res.vendor.toString());
console.log("vendor name"+res.vendor.toString());
g_form.setValue('u_exam_name1',res.exam.toString());
console.log("exam name "+res.exam.toString());
 
}
 
//Type appropriate comment here, and begin script below

Script include
getVendorNExam:function(){
var obj={vendor:'',exam:''};
var lcr = this.getParameter('sysparm_lcr');
var gr = new GlideRecord("u_license_request");
gr.addQuery("sys_id", lcr);
gr.query();
if (gr.next()) {
obj.vendor=gr.u_vendor.toString();
obj.exam=this.getExam(gr.u_certificate.toString(),gr.u_vendor.toString());  
}
return JSON.stringify(obj);
 
 
},

 

can anyone suggest what is going wrong

1 REPLY 1

Tai Vu
Kilo Patron
Kilo Patron

Hi @avinashdubey103 

Can you share the script behind this function getExamIs there any value return from this function?

At this line => this.getExam(gr.u_certificate.toString(), gr.u_vendor.toString()); 

 

If the LCR variable is in Reference type, let's try the Auto-populate feature below.

Sample below for autofilling the User's Email based on the Requested for reference variable.

TaiVu_0-1700466163263.png

 

Cheers,

Tai Vu