How to override a field from a reference table

jmweli
Kilo Expert

Hi ServiceNow Community Developers,

 

I am currently configuring the problem form and one of the fields I have is a vendor field (custom) which is a reference to cmdb_ci table. The display field on the cmdb_ci table is the name. When I click the reference icon (magnifying glass) on the vendor field to do the lookup on the cmdb_ci table I see the list of config items. I have customized this lookup list to only show me vendor and name (both fields are oob). When I select a config item from the lookup list I would like the vendor field on my form to be populated by the vendor field from the lookup list but that is not happening, instead the system populates the vendor field on my form with name field from the lookup list. I know that this behavior is caused by the fact that the name is the display field on the cmdb_ci table however I would like a way to override this behavior when I do a config items data lookup coming from the problem table so that I am able to display the vendor instead of name. Please advise.

 

Thanks,

Johannes

1 ACCEPTED SOLUTION

Jake Gillespie
Mega Guru

You can't override the display value that have been defined as this is a dictionary property of the source table (Configuration Item). However, you might be able to modify your form to display the value you want in another way. Adding the related field (Vendor from the Configuration Item record etc), or you could add a new string field and populate it using an onChange Client Script, which accesses the Configuration Item Record. The g_form.getReference() method could be used to do this, but it would only return the Configuration Item record, and since Vendor is a reference to another table, you would ultimately need to access that value. Using GlideAjax, you could make a call to the server and retrieve any value from the Vendor record, after the Configuration Item field has been populated (since you would look up this record to obtain the sys_id of the vendor record). Once you have the value, this could then populate the new string field you added to the form.



Regards,


Jake


View solution in original post

8 REPLIES 8

exactly what i tried to convey adding the related field is much simpler


jmweli
Kilo Expert

Thank you very much guys for your suggestions. I implemented this according to the suggestions you gave me and it works fine.


Ho Johannes,



I'm glad to hear your issue has been resolved. Could you please take the time to mark any of the above posts as "helpful" or "correct". This will ensure other users benefit from the knowledge shared on the thread.



Regards,


Jake


Hi Jake,



I meant to do that yesterday but could not find the button to click. Once again thank you so much for all your help guys



Johannes