- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2016 09:40 PM
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::
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:
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2016 08:51 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2016 10:20 PM
Hello,
Can you check if you have AbstractAjaxProcessor script include present in your instance?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2016 10:20 PM
In case it is present Please check if it is active or not empty.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2016 10:26 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2016 10:30 PM
Then it should not be a library issue. Must be issue with the parameter passing or something.
can you cope/ paste the two codes in here please (Please do not post screenshot.), I will run in my sandbox and will reply ASAP.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2016 10:39 PM
Hi Prasun,
Below is the "Script Include" I have defined:
var getCallerData = Class.create();
getCallerData.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getSysID: function() {
var gr = new GlideRecord('customer_contact');
gr.addQuery('phone=' + this.getParameter('sysparam_phone_number'));
gr.query();
if (gr.next()) {
return gr.sys_id;
}
return 'no-match';
},
type: 'getCallerData'
});
Below is the JavaScript code I have defined in my client browser:
var ga = new GlideAjax('getCallerData');
ga.addParam('sysparam_name','getSysID');
ga.addParam('sysparam_phone_number',"(974) 133-3111");
ga.getXMLWait();
alert(ga.getAnswer());
Thanks in advance.
Regards
Mahendra
9741333111