
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2024 02:08 AM
Hi,
I have created a glideAJAX and scriptInclude script to autopopulate the values. I am getting an error saying TypeError: addParam is not a function. Kindly help.
GlideAJAX
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('officerNameClass');
ga.addparam('sysparm_name', 'officerNameFunction');
ga.addparam('sysparm_id', newValue);
ga.getXML(callBackFunction);
function callBackFunction(response){
var answer = response.responseXML.documentElement.getAttribute('answer');
var op = JSON.parse(answer);
g_form.setValue('user_id_officer', op.userid);
g_form.setValue('office_phone_officer', op.officePhone);
g_form.setValue('cost_center_officer', op.costCenter);
}
}
ScriptInclude
var officerNameClass = Class.create();
officerNameClass.prototype = Object.extendsObject(AbstractAjaxProcessor, {
officerNameFunction: function() {
var officeKey = this.getParameter('sysparm_id');
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', officeKey);
gr.query();
if(gr.next()){
var jsonObj = {};
jsonObj.userid = gr.getValue('user_name').toString();
jsonObj.officePhone = gr.getValue('phone').toString();
jsonObj.costCenter = gr.getdisplayValue('cost_center').toString();
var json = JSON().encode(jsonObj);
}
},
type: 'officerNameClass'
});
Regards
Suman P.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2024 02:11 AM
HI @Community Alums ,
Param not param "P" is capital
var ga = new GlideAjax('officerNameClass');
ga.addParam('sysparm_name', 'officerNameFunction');
ga.addParam('sysparm_id', newValue);
Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2024 02:11 AM
HI @Community Alums ,
Param not param "P" is capital
var ga = new GlideAjax('officerNameClass');
ga.addParam('sysparm_name', 'officerNameFunction');
ga.addParam('sysparm_id', newValue);
Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2024 02:16 AM - edited 12-06-2024 02:18 AM
Hello @Community Alums ,
You can follow the below script include and client script code.
Script Include: -
var officerNameClass = Class.create();
officerNameClass.prototype = Object.extendsObject(AbstractAjaxProcessor, {
officerNameFunction: function() {
var officeKey = this.getParameter('sysparm_id');
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', officeKey);
gr.query();
if(gr.next()){
var jsonObj = {};
jsonObj.userid = gr.getValue('user_name').toString();
jsonObj.officePhone = gr.getValue('phone').toString();
jsonObj.costCenter = gr.getdisplayValue('cost_center').toString();
var json = JSON().encode(jsonObj);
return json;
}
},
type: 'officerNameClass'
});
Client script:-
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('officerNameClass');
ga.addParam('sysparm_name', 'officerNameFunction');
ga.addParam('sysparm_id', newValue);
ga.getXML(callBackFunction);
function callBackFunction(response){
var answer = response.responseXML.documentElement.getAttribute('answer');
var op = JSON.parse(answer);
g_form.setValue('user_id_officer', op.userid);
g_form.setValue('office_phone_officer', op.officePhone);
g_form.setValue('cost_center_officer', op.costCenter);
}
}
Please mark my answer as accepted solution and give thumbs up, if it helps you.
Regards,
Abhishek Thakur