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

Mohith Devatte
Tera Sage
Tera Sage

Hello @venkatraman ,

so if i understood it correctly you want the sys_id of the reference variable instead  of name while mapping ?

how are you mapping it to custom table field and what type of field is storing the name of the referenced record can you tell me that ?

Yes i want the sys_id of the reference variable's value. And I was mapping it via map to field to the column in the table. And the column type is string only.

OKay then try to do this in your record producer script and remove map to field .

Your below line will map it to you can remove map to field

current.your_field_name = producer.your_reference_variable_name

this will store the sys_id of it 

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

to which target field you want the variable to be mapped?

the target field can be reference type and referring to the same table as that of the variable and you can directly map it

regards
Ankur

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