Error while calling Script Include from Client Script

rpoola
Tera Contributor

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'

};

6 REPLIES 6

Not applicable

Hi Ravikiran,



It looks like you have not made your script include client callable.



Make sure you select the "Client callable" check box as shown below.



find_real_file.png



Note the change in the first two lines of script.



Thanks,


Mohammed Zeeshan


rpoola
Tera Contributor

Hi Zeeshan,


Thank you immediate response. I have selected the check box. This is something else.


find_real_file.png


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.



Check https://developer.servicenow.com/app.do#!/lp/servicenow_application_developer/app_store_learnv2_scri...



Regards,


Darshak


karthikdurga
Mega Expert

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'


});