Show name instead of sys_id in string field populated by variable

ebaileyybs
Tera Expert

Hi,

I have a variable which is referencing a list of data in a bespoke table (x_yobs_regulatory_regulatory_breach_tier_1)

The variable is tier_1

find_real_file.png

I want the name of the data entry to appear in a mapped string field on the associated table instead of it's sys_id. The field needs to be string for another purpose so this cannot be changed.

find_real_file.png

Currently when the form is submitted it show the sys_id as below but I need it show show the label/name

find_real_file.png

How can i achieve this?

Thanks in advance.

Emma

26 REPLIES 26

marcguy
ServiceNow Employee
ServiceNow Employee

if your setting this field via script you should be able to dot walk to the name:



current.variables.tier_1.name (or u_name)



alternatively, you could make the variable a 'lookup select' type variable, similar to reference but changes it to a dropdown, but then you can specify which field from the lookup table to store the value of, i.e. name so no scripting required.


Hi, thanks for your reply.



Can you expand on the first suggestion please?



I'm not able to use lookup select box as the the fields are dependent and the data doesn't transfer through correctly.



Thanks,
Emma


marcguy
ServiceNow Employee
ServiceNow Employee

understood, in which case we can use a script to grab the name from the reference variable in the producer, before we transfer it to a real record and lose the reference field.




in your producer script you should be able to do this instead of mapping the 2 fields



current.fieldname(your string field) = producer.tier_1.name;



try that and see if it works.


Hi, I have removed the mapping and added the code to the script on the record producer but it is still showing the sys_id



find_real_file.png



find_real_file.png



find_real_file.png



Do you know where I'm going wrong?



Thanks for your help!