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

Prateek kumar
Mega Sage

You can use current.reference_feild_name


Please mark my response as correct and helpful if it helped solved your question.
-Thanks

Nithish1
Tera Guru

Hi,

 

Try .getUniqueValue();

 

Thanks,

Nithish

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.

Thank you this worked!

snehlatamishra
ServiceNow Employee
ServiceNow Employee
var gr = new GlideRecord("table_name");
gr.query();

while(gr.next())
gr.ref_field_name.getRefRecord().getUniqueValue()