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 11:03 PM
Hi Ravi,
In your client script you have define a variable as start_date that is wrong, you have to keep the sysparm with all the variables, so your variable should be like sysparm_start_date and the get value form this variable in script include.
http://wiki.servicenow.com/index.php?title=GlideAjax#Using_GlideAjax : Any extra parameters may be passed in, all of which must begin with sysparm_.
it should be like ajax.addParam('sysparm_start_date', cdt); in your client script's 7th Line
it should be like var start_date = this.getParameter('sysparm_start_date'); in your script include's 5th Line
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2017 11:53 PM
Hi Poola,
Have highlighted the changes in bold.
The script should be as following:-
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('sysparm_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('sysparm_start_date');
var start_date_GD = GlideDateTime(start_date);
start_date_GD.addDays(7);
return start_date_GD;
},
type: 'VBODateTimeUtils'
};
Hoping this helps.
Regards,
Dhruv Chandan