Uncaught ReferenceError: GlideAjax is not defined

mahdyy
Kilo Contributor

Hi,

I am new to ServiceNow and trying some hands on GlideAjax/GrideRecord scrtpting. I have created a new "Script Include" with "Client Callable" => TRUE. While trying to invoke the same from the client web browser using JavaScript using "GlideAjax", I am facing the error - "Uncaught ReferenceError: GlideAjax is not defined" I have even tried to use "GlideRecord" but getting the same reference error.

Below is the Script Include I have defined in the system::

find_real_file.png

The client-side script I have written to call the Script Include is as below:

                  var ga = new GlideAjax('getCallerData');

                  ga.addParam('sysparm_name','getSysID');

                  ga.addParam('sysparm_phone_number',"(080) 224-1097");

                  ga.getXMLWait();

                  alert(ga.getAnswer());

The error screen-shot is:

find_real_file.png

Am I missing in enabling something which will then include the necessary javascript libraries related to GlideAjax/GlideRecord in the client side?

I am using "glide-helsinki-03-16-2016__patch4-08-10-2016_08-27-2016_1002".

Thanks in advance.

Regards

Mahendra

1 ACCEPTED SOLUTION

Hi Mahendra,



I have replied to your email with necessary links and it worked perfectly fine. I have created a client script in incident form view and it is working as expected.


View solution in original post

20 REPLIES 20

Abhinandan Pati
Giga Guru

Hi Mahendra,



There is a typo in getSysID method[sysparam_phone_number]. And the way you passed a parameter in addQuery is not correct. Correct these & try.



Thanks


Abhinandan


Thanks Abhinandan, I have corrected the errors in syntax. However, the issue I am facing is at the first line itself "var ga = new GlideAjax('getCallerData');" where the GlideAjax() call is getting failed in my client browser end due to the unavailability of JS library reference. Can you please help in this regard?


Prasun
Giga Guru

Hello Mahendra,



use the script. You have typos and other format issues in the GlideRecord block.



var gr= new GlideRecord('customer_contact');


gr.addQuery('phone',this.getParameter('sysparm_phone_number');


gr.query();


mahdyy
Kilo Contributor

Thanks Prasun, I have corrected the errors in syntax. However, the issue I am facing is at the first line itself "var ga = new GlideAjax('getCallerData');" where the GlideAjax() call is getting failed in my client browser end due to the unavailability of JS library reference. Can you please help in this regard?