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

is name the correct field name or if it's a custom table it's not u_name is it?


Hi, yes it's right.



find_real_file.png


marcguy
ServiceNow Employee
ServiceNow Employee

strange it's almost like the mapping is still happening rather than the producer script kicking in.



can you just see if we are getting the name by putting a gs.log entry in?



gs.log('tier name is ' + producer.tier_1.name);



then check the log to see if we are picking that up or not?


Hi,



I've updated to the following - where do i check the logs please?



gs.log(current.tier_1 = producer.tier_1.name);


gs.log(current.tier_2 = producer.tier_2.name);


gs.log(current.tier_3 = producer.tier_3.name);



Thank you!!


org.mozilla.javascript.EcmaError: "FormInfoHeader" is not defined.


    Caused by error in <refname> at line 8



          5: s += 'The Regulatory Breach department will contact you if they need any further information<br/>';


          6: fi.addMessage(s);


          7: current.contact_type = "self-service";


==>     8: gs.log(current.tier_1 = producer.tier_1.name);


          9: gs.log(current.tier_2 = producer.tier_2.name);


        10: gs.log(current.tier_3 = producer.tier_3.name);