Search field on the UI page should be able to search on multiple fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2022 06:06 PM
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>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2022 11:09 PM
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"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2022 12:33 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2022 01:00 AM
share your updated script which you tried.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2022 11:54 AM
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>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2022 01:00 PM
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.