- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2024 03:43 AM
Hi All,
I am wondering if getreference with a callback function is still a relevant feature which we can use or do we have something else or do we always need to use GlideAjax if we need some values from backend to frontend.
Also does it hampers the performance even if it is used in a callback function.
Thanks in advance.
Solved! Go to Solution.
- Labels:
-
Best Practices
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2024 04:29 AM
Hi @Anubhav24 - Absolutely. GlideAjax is both recommended and best practice as per the Best Practice article directly on ServiceNow's developer site:
@Anubhav24 - To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Helpful.
Thanks, Robbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2024 03:56 AM
Hi @Anubhav24,
In short, the reason why a getReference() callback is not recommended is because the method retrieves all fields in the requested GlideRecord when in most cases only one field is required (or perhaps one or 2 fields rather than all fields which can be as many as 30+ depending on the table you're querying against)
It is this additional 'weight' that adds and impacts performance. Hence the recommendation of GlideAjax.
Below is a link to the Best Practices directly from SN with the 'why'.
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Helpful.
Thanks, Robbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2024 04:19 AM
Hi @Robbie @Aman Kumar S ,
Thanks for your replies , to summarize we should keep avoiding getreference unless it becomes a necessity which in any case might not since we will be using GlideAjax.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2024 04:29 AM
Hi @Anubhav24 - Absolutely. GlideAjax is both recommended and best practice as per the Best Practice article directly on ServiceNow's developer site:
@Anubhav24 - To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Helpful.
Thanks, Robbie

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2024 04:01 AM
Hi @Anubhav24
Using getReference is still valid and used, but with awareness around using async ajax and performance impact of getRefReference people have started using ajax calls instead of sync call with callback function.
g_form.getReference just ends up calling the client-side GlideRecord API. In my opinion, client-side GlideRecord should be avoided as much as possible, since it usually results in a lot of data being transferred needlessly.
Although, in catalog due to limitation to async glideajax, getref is used if you are performing validation for onSubmit client script.
Aman Kumar