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

akt_snow
Giga Expert

Did you try using dictionary override?


jmweli
Kilo Expert

Hi Avneet,



I don't have the dictionary override option because the field I am working with is not on an extended table.


Kalaiarasan Pus
Giga Sage

dont think this is possible...



but since this is reference field, you can right click > personalize > form layout > select the field > click plus sign in the middle > add the field required to the form layout...


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