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,702 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Saturday
Hi @ishankaggarwal ,
The getReference() method is used in GlideRecord and GlideForm (client scripts) to retrieve the full record of a reference field.
Key Points
- A reference field only stores the sys_id of the related record.
- If you want details (like the user’s name, email, or department from a caller_id field), you use getReference() to pull the entire referenced record.
- On the client side, it works asynchronously — you provide a callback function to handle the returned record.
Example – Client Script
// On a form with a reference field 'caller_id'
g_form.getReference('caller_id', function(userRecord) {
var phone = userRecord.phone;
var email = userRecord.email;
alert("Caller Phone: " + phone + " | Email: " + email);
});
Thanks,
Afrith
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sunday
getReference() is used to fetch the full GlideRecord of a reference field.
For example, if you have a reference field like Caller (caller_id) on an Incident:
g_form.getValue('caller_id') → only returns the sys_id.
g_form.getReference('caller_id', function(caller) { ... }) → returns the full user record so you can access fields like caller.name, caller.email, etc.
This is useful when you need additional details of the referenced record in client scripts.
Regards,
Pranita D
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sunday
getReference() is used to fetch the full GlideRecord of a reference field.
For example, if you have a reference field like Caller (caller_id) on an Incident:
g_form.getValue('caller_id') → only returns the sys_id.
g_form.getReference('caller_id', function(caller) { ... }) → returns the full user record so you can access fields like caller.name, caller.email, etc.
This is useful when you need additional details of the referenced record in client scripts.