How can I get sys ID from reference field? I am using client script. Please see description below.

Ramesh4
Giga Contributor

I have a field name is  Xyz and a reference from another job family table, I don't know to get sys Id for Xyz. Could you please help me with this?

Appreciate your help.

7 REPLIES 7

Dan H
Tera Guru

Hi,

var xyzSysId = g_form.getValue('xyz');

xyzSysId will contain the sys id.

 

Hope this helps

Please mark my answer as Correct/Helpful based on impact

Regards,

Dan H

 

Ramesh4
Giga Contributor

 Thank you for responding so quickly.

Is there a different method to retrieve the sys id? I'm still not receiving a sys id for Xyz when I use>

var xyzSysId = g_form.getValue('xyz');

Appreciated your help.

No problem.

Are you not trying to do this from a client script?

If you are doing this is a background script or a business rule it will be different.

Ultimately, you need to have the GlideObject for the record, so current. or gr. for example.

and then append .getValue('xyz')

var sysid = current.getValue('field_name');

var sysid = gr.getValue('field_name');

Make sure you are using the field name and not the field label. If you right click the field you can see the field name.

If you have any more information or screenshots, I can help.

thanks

Shakeel Shaik
Giga Sage
Giga Sage

HI Ramesh,

 

What is the field value(Backend value) of Xyz?

 

Lets say your Xyz field is know Assigned to field

Steps:

Right click on field Name

 find_real_file.png

  1. You will get to see Show

find_real_file.png

3. Here u_assigend_to is a field Value or Backend Value

 

 

You can Run this on Background Script

var rec = new GlideRecord('incident'); // replace incident with your table name
//rec.addActiveQuery(); //Customize your query as per requirement
rec.query(); 
if(rec.next()) { 

  gs.print(rec.u_assigned_to); 

}

here you will get sys_id in return

 

 

If my Answer is helpful to you, Please mark as Correct Answer/Helpful

Please check and Let us know.

Thanks:)

 

 

Thanks,
Shakeel Shaik šŸ™‚