The CreatorCon Call for Content is officially open! Get started here.

Search field on the UI page should be able to search on multiple fields

RiteshAlla
Mega Sage

Hi Team,

Currently i have a search field on the UI page searching on sys_user table. This search filed currently only allows me to search by users name.

How do i make this field to be able to search by email, userid, company or any other fields on the user table?

Please help

Ps: Client script code as attached.

HTML Code:

<?xml version="1.0" encoding="utf-8" ?>

<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

<html>
<body>
<h1> Select by a User or a Company </h1>
<table>
<th>Select a User:</th>
<th><g:ui_reference name="userRecords" id="userRecords" table="sys_user" completer="AJAXTableCompleter" onchange="generateTable()" /></th>
</table>
<br/>
<div id="dvTable2" style="overflow: hidden; height: 100%; width: 100%; position: absolute;" height="100%" width="100%">
</div>
<br/>
</body>
</html>
</j:jelly>

10 REPLIES 10

RiteshAlla
Mega Sage

Hi @Kalyani Jangam1 

For some reason same code does not work on my page. Not sure what or where i am doing wrong. Will it be some thing to do with the client script too? I have attached the client script to this question as well.

Name as below

name="userRecords" id="userRecords" table="sys_user"

 

Kalyani Jangam1
Mega Sage

Hi @RiteshAlla 

there is no required for client script, it will work only in html code also. Try to remove client script code and <g:ui_reference name="userRecords" id="userRecords" table="sys_user" completer="AJAXTableCompleter" columns="user_name;email;department" onchange="generateTable()" /> and just use correct field name not field label. Initially use 2 columns and if it is working then try for 3 or 4 columns.

Ankur Bawiskar
Tera Patron
Tera Patron

@RiteshAlla 

share your updated script which you tried.

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

RiteshAlla
Mega Sage

Hi @Ankur Bawiskar and @Kalyani Jangam1 

Updated script as below - Html code. I havent changed anything on Client Script. It is still the same as attached text file.

<?xml version="1.0" encoding="utf-8" ?>

<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

<html>
<body>
<h1> Select by a User or a Company </h1>
<table>

<th>Select a User:</th>
<th><g:ui_reference name="userRecords" id="userRecords" table="sys_user" columns="user_name;email;department" completer="AJAXTableCompleter" onchange="generateTable()" /></th>

</table>

<br/>
<div id="dvTable2" style="overflow: hidden; height: 100%; width: 100%; position: absolute;" height="100%" width="100%">
</div>

</body>
</html>
</j:jelly>

RiteshAlla
Mega Sage

Hi @Ankur Bawiskar and @Kalyani Jangam1 

When i use columns  as suggested above, i can see the list of users with their columns(like email, department, company) showing okay.

That is not my problem. In the search bar, i should be able to search by a users email or username or department other than their name. Currently i can search only using their name.

For example if i type in a users email in the search bar - no results come up.