The CreatorCon Call for Content is officially open! Get started here.

What is the use of getReference()?

ishankaggarwal
Tera Contributor

What is the use of getReference()?

17 REPLIES 17

Afrith Shariff
Tera Guru

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

pranita-24
Tera Guru

Hi @ishankaggarwal 

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.

Please hit like and mark my response as correct if that helps
Regards,
Pranita D
 
 
 
 
 
 

pranita-24
Tera Guru

Hi @ishankaggarwal 

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.