ServiceNow Glide Ajax User information Auto-populate |ServiceNow Glide Ajax example | Servicenow tip
TechnoMonk
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 S ... https://www.youtube.com/watch?v=jAAClJ0Ld6o
52905121 Bytes