UI Page with a UI Reference field that searches multiple fields and shows specific columns

Suvitha Murugan
Tera Contributor

I need the search to work on the Name, Last Name, and Email fields. Currently, it only searches the Name field. The user should be able to find a record by any of these fields. Also, during the search, only two names are shown—how can I display specific fields that I want in the search results?

  <g:ui_reference name="user" id="user" table="XXXresp" query="${qual}" completer="AJAXTableCompleter" attributes="ac_columns=user;user.email;user.user_name,ac_columns_search=true,ac_search_fields=user.last_name,ac_display_value=false" columns="user;user.email;user.user_name" />



SuvithaMurugan_0-1765188293977.png

 

Thanks in Advance

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@Suvitha Murugan 

Not directly possible within UI page

but here is a possible workaround

-> the fields you want to allow searching should have ref_ac_columns and ref_ac_columns_search added in attributes in dictionary

-> then only UI page will allow user searching on it

AnkurBawiskar_0-1765190105969.png

 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

@Suvitha Murugan 

Hope you are doing good.

Did my reply answer your question?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

kaushal_snow
Giga Sage

@Suvitha Murugan ,

 

You can’t make a single <g:ui_reference> on a UI Page search more than the default display field.....even if you supply attributes like ref_ac_columns and ref_ac_columns_search=true, because the built in UI Page auto completer does not honor those extended attributes.......If you really want search on name, last name, email and show multiple columns, the working solution is to create a real reference field in the dictionary pointing to your target table, add dictionary attributes ref_auto_completer=AJAXTableCompleter, ref_ac_columns=name;last_name;email, ref_ac_columns_search=true, then use that field via <g:ui_reference> only then will autocomplete search across the added columns and show them in the drop down......

 

If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community.

 

Thanks and Regards,
Kaushal Kumar Jha - ServiceNow Technical Consultant - ServiceNow Class of Legends 2025

@kaushal_snow 

It seems the same approach was shared earlier, about four hours ago. To avoid any confusion, I suggest we refrain from repeating the same information.

 

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