What is difference between GLIDE AJAX Call and getReference() call In client script.

srikanth241
Mega Expert

Hi Team,

                            Can anyone explain the difference between glide ajax call and getReference() call in client script, can you give some examples when should we use. Which is the best to use from performance view.

thanks ctomasiITSM: GeneralIT Service ManagementDeveloper CommunityServiceNow Community

1 ACCEPTED SOLUTION

The SN Nerd
Giga Sage
Giga Sage

GlideAjax - returns only the data you specify, does not block the browser when using .getXML()


getReference - returns all fields on the record, does not block the browser when using callback function.



GlideAjax will always give the best performance, but is significantly more complex to code.



You should use GlideAjax if your code is intended for production.



ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

View solution in original post

5 REPLIES 5

fkhan
Kilo Guru

Hi Abhai,




GlideAjax: The GlideAjax allows you to trigger server-side code from the client side. the main benefit of GlideAjax that you can easily calls pass parameters to the script includes and using naming conventions, allows the use of these parameters.



getRefference: The getReference() method of g_form supports a callback function as well, and the usage is almost the same! The only difference is that getReference accepts two arguments (the first being the field name as a string, and the second being a reference to your callback function)



For more info check this link :SN Pro Tips — GlideRecord & GlideAjax: Client-Side Vs. Server-Side



Thanks,


Farukh


Pradeep J
Kilo Guru

Hi Abhay,



GlideAjax() is server side call and getReference() is client side call.


Below thread may help you to understand more.


Replace g_form.getReference with GlideAjax?




Thanks


Pradeep D J



PS - Please mark Helpful, Like, or Correct Answer if applicable.


Harsh Vardhan
Giga Patron

Hi Abhay,




Please check the below thread.


GlideAjax: GlideAJAX API



getReference(): it's glideform (g_form) class method. this function will only run on client side.


g_form.getReference() are also available for retrieving server information. no longer recommended due to their performance impact.




If you have requirement to retrieve some information from server then always use glideAjax.



Please find the below example link.



GlideAjax - ServiceNow Wiki




Thanks,


Harshvardhan




PS: Hit like, Helpful or Correct depending on the impact of the response


The SN Nerd
Giga Sage
Giga Sage

GlideAjax - returns only the data you specify, does not block the browser when using .getXML()


getReference - returns all fields on the record, does not block the browser when using callback function.



GlideAjax will always give the best performance, but is significantly more complex to code.



You should use GlideAjax if your code is intended for production.



ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022