Make reference field searchable by 2 different fields.

Filipe5
Kilo Expert

Hello all,

 

I am new to ServiceNow and have an existing reference field on a form where users can search for a company by name:

find_real_file.png

 

I need to make it so that users can also use the same field to search by a different value (a 4 digit code), that most companies on our database also have, and present the company name if any is found (the same way it's currently happening).

 

Is it possible to change the current reference field to include that option, or would it be simpler to create a new field and populate either with info from the other one?

 

Thanks in advance for any help!

5 REPLIES 5

umaaggarwal
Giga Guru
Giga Guru

Hi Filipe,

 

you can pass this in attribute value : 

ref_auto_completer=AJAXTableCompleter,ref_ac_columns=name;code,ref_ac_columns_search=true;

the part in red color give the columns you want your search to be based on. You can replace the field names with what you want. I have used name and code hypothetically 

 

Hope this helps. If yes, please mark correct and helpful

 

Regards!

Uma

 

Hi,

 

I followed your instructions and also checked the links Sandeep posted, but it's not working.

It still only searches for the company name (same as before) and doesn't give me any results when I search for the phone number instead:

ref_auto_completer=AJAXTableCompleter,ref_ac_columns=name;phone,ref_ac_columns_search=true

find_real_file.pngfind_real_file.png

 

Both fields belong to the same table, however I noticed that the table being referenced is not the same (task instead of core_company), might it have something to do with it? It's still searching for the company name (or other fields when opening the search window) correctly, so I don't think so:

find_real_file.pngfind_real_file.png

 

Thanks again for you help.

 

Community Alums
Not applicable

Hi Filipe,

You can have a look in deep to the following thread discussion, it should fit your need:

https://community.servicenow.com/community?id=community_question&sys_id=98b1cb69db98dbc01dcaf3231f96...

https://community.servicenow.com/community?id=community_question&sys_id=94eef7d1dba16c10fb115583ca96...

Mark my answer correct & Helpful, if Applicable.

Thanks,
Sandeep

Hi Sandeep,

 

I followed the instructions on the links and used the following code:

ref_auto_completer=AJAXTableCompleter,ref_ac_columns=name;phone,ref_ac_columns_search=true

 

However it's still not working. In fact if I remove "name" and leave only "phone", the field keeps accepting only searches with the name of companies:

ref_auto_completer=AJAXTableCompleter,ref_ac_columns=phone,ref_ac_columns_search=truefind_real_file.png

Can you tell what I might be missing?

Thanks again for your help.