How to set the value in the reference field when you have name

shaik_irfan
Tera Guru

Hi

I have a value like which is the name of the location which i need to set in the refernence field which is location.

 

Can i do like below?

 

gr.u_location = "India"; // u_location is a reference field

1 ACCEPTED SOLUTION

johnfeist
Mega Sage
Mega Sage

Hi Shaik Irfan,

What you need to do is something like this:

var locations = new GliedRecord("cmn_location");
locations.get("name",<variable or literal with the name>);
gr.setValue("u_location", locations.sys_id);

Hope that helps.

:{)

Helpful and Correct tags are appreciated and help others to find information faster

Hope that helps.

:{)

Helpful and Correct tags are appreciated and help others to find information faster

View solution in original post

6 REPLIES 6

@shaik.irfan 

Did you try this approach?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar , i did tried my lead recommended to go with gliderecord the user table considering wrong name or empty spaces may set to inconsistency