js_includes_sp.jsx?v= (g_env) [SCRIPT:EXEC] Error while running Client Script "Auto populate the RITM fields": ReferenceError: GLideAjax is not defined
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2018 04:09 AM
Here's my Client Script ------
function onChange(control, oldValue, newValue, isLoading) {
var g=new GLideAjax('AutoPopulateUsrFields');
ga.addParam('sysparm_name','getPhoneNumber');
ga.addParam('configuration',g_form.getValue('ritm'));
ga.getXML(updateFields);
function updateFields(response){
var answer=response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('phone_no',answer);
g_form.setReadOnly('phone_no',true);
And also for that i have Written the Script Includes------
var AutoPopulatePhoneField = Class.create();
AutoPopulatePhoneField.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getPhoneNumber:function(){
var phone_no;
var server=this.getParameter('configuration');
var item = new GlideRecord("sc_req_item");
item.addQuery("number", server);
item.query();
if (item.next()) {
var var_own = new GlideRecord('sc_item_option_mtom');
var_own.addQuery('request_item', item.sys_id);
var_own.orderBy('sc_item_option.item_option_new.order');
var_own.query();
while (var_own.next()){
if(var_own.sc_item_option.item_option_new.question_text== 'Phone no'){
phone_no=eval('item.variable_pool.'+var_own.sc_item_option.item_option_new.name+'.getDisplayValue()');
}
}
}
can you please let me know what i went Wrong in this ???
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2018 11:26 AM
There is a capital letter in "GLideAjax" it needs to be "GlideAjax".
Also you can use:
ga.getXMLAnswer(updateFields);
and edit the line:
function updateFields(answer)
and remove the line:
var answer=response.responseXML.documentElement.getAttribute("answer");
Your Script Include is not returning anything to the client.
You need to add something like:
return myAnswer;
which is than the answer parameter of your updateFields function.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2018 10:51 PM
I want to auto populate the phone_no field with the reference of RITM I am writing this code below please correct me if you have any findings there.
SCRIPT INCLUDE-
var AutoPopulatePhoneField = Class.create();
AutoPopulatePhoneField.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getPhoneNumber:function(){
var phone_no;
var server=this.getParameter('configuration');
gs.log("server:"+server);
var item = new GlideRecord("sc_req_item");
item.addQuery("number", server);
item.query();
if (item.next()) {
gs.log("item.next");
var var_own = new GlideRecord('sc_item_option_mtom');
var_own.addQuery('request_item', item.sys_id);
var_own.orderBy('sc_item_option.item_option_new.order');
var_own.query();
while (var_own.next()){
gs.log("while");
if(var_own.sc_item_option.item_option_new.question_text== 'Phone no'){
phone_no=eval('item.variable_pool.'+var_own.sc_item_option.item_option_new.name+'.getDisplayValue()');
gs.log("abc"+phone_no);
}
else{
gs.log("else");
}
}
}
gs.log(phone_no);
return(phone_no);
},
type: 'AutoPopulatePhoneField'
});
CLIENT SCRIPT----
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') { //if loading or new value is blank, do nothing
return;
}
var ga=new GlideAjax('AutoPopulatePhoneField');
ga.addParam('sysparm_name','getPhoneNumber');
ga.addParam('sysparm_configuration',g_form.getValue('ritm'));
console.log(g_form.getOption('ritm')+" koi,jiuj,niuj,9up");
ga.getXML(updateFields);
function updateFields(response){
console.log("answer");
var answer=response.responseXML.documentElement.getAttribute("answer");
alert(answer);
g_form.setValue('phone_no',answer);
//g_form.setReadOnly('phone_no',true);
}
}
I will be highly appreciate for your help if you can fix this.