GlideRecord or GlideAjax?

Ravish Shetty
Tera Guru

In my previous organization where I started with ServiceNow we were advised to use GlideAjax in async mode on client side scripts instead of GlideRecord. GlideRecords too can work in async mode. So was this advise incorrect?

1 ACCEPTED SOLUTION

Depends what you are trying to achieve really.



aysnc client side gliderecord is is identical as far as I can tell as an async glideajax call (performance wise aswell ) as they both send the request and await the response with a callback function.



HOwever be careful with your queries, client side glide records adhere to ACLs whereas server side ACLs do not. So if the information is secure away from the user via an ACL, you'll need to use a glideajax call.


View solution in original post

17 REPLIES 17

I stand corrected - thanks for pointing that out.   You learn something everyday.  


treycarroll
Giga Guru

Hi Ravio,



The Client Side best practices document on the wiki confirms this advice.



Other methods, GlideRecord and g_form.getReference() are also available for retrieving server information. However, these methods are no longer recommended due to their performance impact. Both methods retrieve all fields in the requested GlideRecord when most cases only require one field.



The documentation on GlideRecord says:


Client-side GlideRecord methods can be called from any client-side script; however, other, more efficient, methods are recommended and should be investigated first. For more information, see Client Script Best Practices




I believe that GlideAjax is favored because it allows you to retrieve only the specific data that you need instead of retrieving all of the fields of the record (as well as any references).     You should also consider using the g_scratchpad variable to send data from an on display BR whenever possible.



Regards,



Trey Carroll


Hi Trey,



Thank you for the reference. I suspect that even when you use GlideAjax, you retreive data of all the fields as ultimately we use GlideRecord in the script include which gets called from the client side.



Regards,


Ravish


Hi Ravio,



Here you can use Display Business Rule and store the user sys_id in Scratchpad variable and use this Scratchpad variable in UI Policy. this will improve performance of the system.



Scripting in Business Rules - ServiceNow Wiki



Regards,


Hima Pallela


Hello Hima,



That script was just an example of how GlideRecord works in asynchronous mode. My query is that is it relevant to use GlideAjax on client side for asynchronous querying purpose when GlideRecord does the same.



Regards,


Ravish