Error while calling Script Include from Client Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2017 08:51 PM
Hi,
I am getting following error while calling script include from client script. I don't have clue. Can anybody help me out.
Problem when trying to get a Rhino object: ConversionError: The undefined value has no properties. (sys_script_include.d22e7bdbc0a8016500a18e024bfc9aa3; line 4):
Client Script :
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
var cdt = g_form.getValue('u_start_date'); //Choose the field to add time from
//alert(cdt);
if(cdt != ''){
var ajax = new GlideAjax('VBODateTimeUtils');
ajax.addParam('sysparm_name', 'addVBODateTimeAmount');
ajax.addParam('start_date', cdt);
ajax.getXML(doSomething1);
}
function doSomething1(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
}
}
Script Include :
var VBODateTimeUtils = Class.create();
VBODateTimeUtils.prototype = {
addVBODateTimeAmount: function(){
//gs.info("Testing");
var start_date = this.getParameter('start_date');
var start_date_GD = GlideDateTime(start_date);
start_date_GD.addDays(7);
return start_date_GD;
},
type: 'VBODateTimeUtils'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2017 09:25 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2017 10:32 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2017 10:54 PM
Hi,
If you are not extending GlideAjax, you need to initialize the class before defining the methods. Since you need it to be client-callable, you need to extend GlideAjax class.
Regards,
Darshak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2017 10:48 PM
The script include is not defined properly. Please change it as below. Hope this is helpful.
var VBODateTimeUtils = Class.create();
VBODateTimeUtils.prototype = Object.extendsObject(global.AbstractAjaxProcessor,
{
addVBODateTimeAmount: function(){
//gs.info("Testing");
var start_date = this.getParameter('start_date');
var start_date_GD = GlideDateTime(start_date);
start_date_GD.addDays(7);
return start_date_GD;
},
type: 'VBODateTimeUtils'
});