GlideAjax
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Explain GlideAjax in a simple way with two to three simple examples
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
59m ago
This is the best explanation
https://www.servicenow.com/community/developer-articles/glideajax-example-cheat-sheet/ta-p/2312430
This helps other users find accurate and useful information more easily
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
48m ago
The important point is:
Client Script → runs in the browser
Script Include → runs on the server
GlideAjax → connects them
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
20m ago
Hello @SRIRAMSANKAR007 ,
GlideAjax is a client side API in ServiceNow that enables client scripts to execute server side code without reloading the webpage. It acts as a performance friendly communication between the browser (Client Script) and the database (Script Include) to retrieve data or perform calculations dynamically.
For Examples :
1) Get today's date/server time :
var DateUtils = Class.create();
DateUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getServerDate: function() {
return new GlideDateTime().getDisplayValue();
},
type: 'DateUtils'
});
client script :
var ga = new GlideAjax('DateUtils');
ga.addParam('sysparm_name', 'getServerDate');
ga.getXML(function(response) {
var date = response.responseXML.documentElement.getAttribute('answer');
alert('Server date: ' + date);
});
2) Passing a parameter: Check if Incident has open Problem
script include :
var IncidentUtils = Class.create();
IncidentUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
hasOpenProblem: function() {
var incidentSysId = this.getParameter('sysparm_incident_id');
var gr = new GlideRecord('problem');
gr.addQuery('rfi', incidentSysId); // example query
gr.addActiveQuery();
gr.query();
return gr.hasNext() ? 'true' : 'false';
},
type: 'IncidentUtils'
});
client script :
var ga = new GlideAjax('IncidentUtils');
ga.addParam('sysparm_name', 'hasOpenProblem');
ga.addParam('sysparm_incident_id', g_form.getUniqueValue());
ga.getXMLAnswer(function(answer) {
if (answer === 'true') {
g_form.showFieldMsg('short_description', 'This incident has a linked open problem', 'warning');
}
});
If my response helped mark as helpful and accept the solution.