What is the use of getReference()?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2018 08:34 AM
What is the use of getReference()?
- 134,698 Views

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2018 08:37 AM
you can use the getReference() to glide that particular record from client side and access the related record of that Glide Object, you can find the more details here: GlideForm - Client
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2018 08:37 AM
Returns the GlideRecord for the field (must be a reference field) you specify in the parameters.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2018 09:29 AM
getReference gets the record used in another reference field. For example you have the Caller ID (reference to the sys_user table) and with getReference, you will retrieve the User record and save this as a gliderecord into a variable. The main reason to use this function is to get more information from the referenced record.
Since this is used client side, it IS a call to the server which may impact performance if used too heavily.
Example:
var gr = g_form.getReference('caller_id');
alert('Caller Email is: ' + gr.email);
Since this is a server call, as already said above, I would recommend using the callback feature (new in Aspen):
var caller = g_form.getReference('caller_id', doAlert); // doAlert is our callback function
function doAlert(caller) { //reference is passed into callback as first arguments
alert('Caller Email is: ' + caller.email);
}
Please refer:
Client Script Examples — ServiceNow Elite
Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-18-2018 05:13 PM
this is one of the best explanations of getReference that I have come across.