Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Getting Sys ID of Reference variable

venkatraman2
Tera Contributor

Hi,

I am having a record producer. In which i am having one variable as a reference of table. Now i am storing the record producer values to a custom table. For that reference variable it is storing the record name in the custom table. But i need to store the Sys id of the reference variable's selected record. Can we use getUniqueValue(). Any solution for this? 

1 ACCEPTED SOLUTION

Hi,

if you directly map it using Map to field then the target string field will hold sysId

If your users are fine with it then it's fine OR else check script I shared.

Regards
Ankur

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

View solution in original post

10 REPLIES 10

But in table column it is a string type. So can i able to store the sys id into the column?

 

Hi,

then use record producer script and get the display value

current.u_target_field = producer.variableName.getDisplayValue();

Regards
Ankur

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

Hi,

if you directly map it using Map to field then the target string field will hold sysId

If your users are fine with it then it's fine OR else check script I shared.

Regards
Ankur

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

It was getting sys id now. But what if i have the custom table column type is reference one. The same map to field method stores the name of the record. How to get sys id in that case.

Hi,

if the target field also refers to same table as that of variable no need to worry.

Regards
Ankur

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