Make reference field searchable by 2 different fields.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2022 04:00 AM
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:
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2022 04:23 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2022 08:27 AM
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
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:
Thanks again for you help.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2022 04:24 AM
Hi Filipe,
You can have a look in deep to the following thread discussion, it should fit your need:
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2022 08:54 AM
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=true
Can you tell what I might be missing?
Thanks again for your help.