Reference field in a variable in a maintain item - show field value code instead of name

rody-bjerke
Giga Guru

Hi,

If I create a variable in a catalog item, and it's a reference to cost center table.

On the cost center table there are fields for Name and Code, but in the reference field only name is shown.

Is it possible to add so that when you search in the field, you can search for value in both name and code fields? and if you list the field, "Code" is the value that it will set? Instead of default Name.

Best regards,

1 ACCEPTED SOLUTION

Dubz
Mega Sage

You can enable the reference field to search for multiple values by adding the below syntax to the attributes on the dictionary entry for the field:



ref_auto_completer=AJAXTableCompleter,ref_ac_columns=YOUR_FIELD_HERE,ref_ac_columns_search=true



You can change the field to display the code value by changing the field which is set as the display value for that table. this will change it for the whole table though so anything referencing it or any script using the display value will be affected.


View solution in original post

4 REPLIES 4

Dubz
Mega Sage

You can enable the reference field to search for multiple values by adding the below syntax to the attributes on the dictionary entry for the field:



ref_auto_completer=AJAXTableCompleter,ref_ac_columns=YOUR_FIELD_HERE,ref_ac_columns_search=true



You can change the field to display the code value by changing the field which is set as the display value for that table. this will change it for the whole table though so anything referencing it or any script using the display value will be affected.


Ankur Bawiskar
Tera Patron
Tera Patron

Hi Rody,



Are you saying that you want to see 2 columns when user clicks on the lookup icon -> update list layout for this


OR


You want to search with either name or code -> use TableCompleter for this



Also if you want to show Code when user selects the value Code column has to be display=true on cost center table. This will affect all places wherever there is a reference to Cost Center table.



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur


grmbr.addQuery('group', 'IN', 'a7846a6d4f3bbe4071165efd0210c717','4da46a6d4f3bbe4071165efd0210c78e','cab4aa6d4f3bbe4071165efd0210c704');


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

Hi Ankur,



I want to search for either name or code (could you give an example of TableCompleter, haven't seen it before)



I assume it's this one:


ref_auto_completer=AJAXTableCompleter,ref_ac_columns=YOUR_FIELD_HERE,ref_ac_columns_search=true



So "YOUR_FIELD_HERE" should be changed to name, code? And i'm not sure where to add this line, i'm in a variable for a catalog item, and i'm using Reference type to a table. User Reference Qualifier = Simple.



Best regards,


In YOUR_FIELD_HERE enter the name of the field on the table you want to search   by, u_name or u_code or whatever they're called (right click on the field and click show to see the field name).



The syntax goes here on the dictionary entry for the reference field:



find_real_file.png