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

Get sys_id of reference field?

JDX7913
Tera Guru

How do you get the sys_id of a reference field via server script? 

I tried the following, but I am getting the displayed name instead of the sys_id. 

'"table".getValue('name')'.
1 ACCEPTED SOLUTION

SanjivMeher
Kilo Patron
Kilo Patron

If Assignment Group is a reference field, I would just do current.assignment_group. I would name add name (current.assignment_group.name), which will give me the display value.


Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

9 REPLIES 9

Nitesh Balusu
Giga Guru

Can you try getUniqueValue() instead?

It is still pulling the display name... 

Thank you this worked!

sachin_namjoshi
Kilo Patron
Kilo Patron

Please check below sample code to get reference field sys  id

In this code, department is reference field on sys_user table.

 

var user = new GlideRecord('sys_user');
user.get('62826bf03710200044e0bfc8bcbe5df1');
gs.print(user.department);

 

Regards,

Sachin