- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2015 10:37 AM
I'm seeing in the Wiki, "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.". However in my Implementation Bootcamp book it has "getReference()" listed as a best practice when used with a callback function. I'm looking for clarification on this is specific reference to the Implementation Specialist exam, and whether the exam would follow the book or the Wiki. Or is it possible I'm not seeing this correctly. Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2015 11:34 AM
Hi Patrick,
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. If you are going to use it, use a callback (g_form.getReference accepts a callback as the second parameter). Client-side GlideRecord can also take a callback (passed in to the query method).
If you are going to use client-side GlideRecord (either through getReference, or directly), do so with a callback so it's non-blocking. However, you rarely need to get the entire record back when doing lookups, so a GlideAjax script which can return only the necessary information is typically a better choice.
Thanks
Cory

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2017 03:56 PM
I recently wrote a blog post about this
How to Write Smart GlideAjax Quickly [Part 2]
Skip to 'The Problem with getReference'
- Round trip
- Too much information
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2017 04:14 PM
excellent Paul, thanks for the link!
So is there EVER a case to use getReference over GlideAjax?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2017 04:17 PM
The case is that it requires less code and faster to get up and running.
GlideAjax scripts can be quite fiddly, alas I wrote the blog to try and make it easier for developers.
The bad being the inefficiency that stacks up over time when getReference it gets over used.
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2017 04:26 PM
right, so given a strong understanding of GlideAjax and script includes, there really isn't a case for getReference, as it tends to be slower, call too much information, and build potential for issues over time.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2017 04:40 PM
Spot on!
My next project for the blog is to finish my code for a new getReference with callback that returns the display value and only the data you need, so you can use almost the same API without the round trip and too much information issue.
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022