Hi All,

In today’s video, we will be looking at a practical use case on the Glide Ajax. We will be looking at how to Auto-populate the use information using Glide Ajax.
You may be asked to populate a field or Variable from a selected User record. I have seen many different solutions that do this, but I have found that an AJAX call method is the most efficient way to pull the information from the user record.

Let’s look into the GlideAjax first
GlideAjax is a class in ServiceNow which is used to execute server-side code from the client-side. Client-side scripts can be Client script, UI policies, UI script, etc. So, the definition clearly says that we must define GlideAjax in client-side scripts. But the Server side code which has to be executed through GlideAjax class should be defined in Script Include.

While defining GlideAjax call-in client-side script we have should take care of the below points:
We should initialize GlideAjax with the name of the script include which we have to use.
The script includes which we will use, we should make sure that the client callable checkbox must be checked.

The client-side script passes parameters using GlideAjax to the Script Include. The parameter uses naming conventions.

For more information on ServiceNow GlideAjax, you can refer to the below link:
Click for GlideAjax ServiceNow Video Tutorial

So make sure that the naming convention must have prefix “sysparm_”. For example, GlideAjax pass function name in parameter which it requires to execute at server end. Some example syntax are mentioned below:

ga.addParam(‘sysparm_name’,’scriptIncludeFunctionName’)
ga.addParam(‘sysparm_firstname’,’Arthur’)
ga.addParam(‘sysparm_location’,’Florida’)

The main benefit of GlideAjax is that we can easily call pass parameters to the ServiceNow script, including naming conventions.

**Remember that ‘sysparm_name’ is always used for parameter function (the function which has to executed in script include) and getXML (), getXMLWait () functions are used to execute the code.

So here the question is, that why do we execute server-side code from client-side?
There are many scenarios where to validate the things we need to execute server-side code from the client-side. Let’s take an example of the incident form, requirement is that the End User can only submit the incident form when his manager belongs to any specific group (for example XYZ group). So here for validation, we can get managers’ group names from the database or from the server. So, in this scenario, we execute server-side code for validating the details.


Different types of GlideAjax in ServiceNow with examples?
We can call execute glide ajax code in two ways synchronously and asynchronously. So, we can say it is of two types:

Asynchronous GlideAjax ServiceNow
In Asynchronous GlideAjax we use get XML () call back functions, through which code runs on the backend to get the response from the server. So, because of that user can proceed with other fields filling, etc.

Synchronous Glide Ajax in ServiceNow
Synchronous GlideAjax uses the getXMLWait () function, so users cannot process with other fields filling or other fields will get freeze until the response is not received from the server.

ServiceNow,glideajax in ServiceNow,ServiceNow tutorial,ServiceNow glideajax,ServiceNow training,glideajax, what is ServiceNow,ServiceNow glideajax example,glideajax in ServiceNow example,ServiceNow tutorial for beginners,servicenow glideajax script include example,servicenow administrator training, introduction to servicenow,servicenow basics,glideajax servicenow docs, what is servicenow administrator,servicenow glideajax server side

Please follow subscribe to my channel Technomonk and press the bell icon to get the latest update on my new videos.
Till then stay happy and safe.
Have a nice day.

Regards,
Amit Gujarathi

technomonkadmin

View all posts

Add comment

Your email address will not be published. Required fields are marked *