- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2017 01:17 PM
Hi Experts, I posted a question about filtering the autocompleter list for a reference field on a UI pages but it doesn't seem like that is doable. Now I'm wondering if it's possible to turn off the autocompleter altogether. My code for the reference field is below:
<g:ui_reference class = "beneficiary" name="family_member_1" id="family_member_1" table="hr_beneficiary" completer="AJAXTableCompleter" columns="employee; beneficiary_contact.relationship;" query = "active=true^employee=javascript:gs.getUserID()" onChange="beneficiary_1();" />
The above code works great, but the autocompleter pulls up all beneficiaries instead of just beneficiaries for the logged in user:
In the picture above, when I type in "J", the autocompleter list should only show me Jacak James Lu and Jill Hu since those are my beneficiaries. Since it seems like this cannot be edited, is there a way to turn this feature off completely? Any suggestions would be super helpful, thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2017 05:15 PM
Hi David,
Try removing active=true from your query or if you have a custom active field on the table, try u_active=true. I have a feeling one of those two scenarios is the case.
Basically errors in queries result in parts of the query being thrown out. I tested g:ui_reference across a couple different tables and a few different scenarios. The one thing I found is that the encoded query will fail silently on you and in very unexpected ways. Basically, any criteria after the "oops" query criteria will be ignored. So here are some examples:
Ref Qual in g:ui_reference ====> Resulting Query
active=true^not_a_field=something ====> active=true
not_a_field=something^active=true ====> no query (all records returned)
active=true^not_a_field=something^numberCONTAINSa ====> active=true
I'll add a note that GlideRecord's addEncodedQuery function does not behave this way and does not return the same results as the g:ui_reference's results. I'm not entirely sure what is going on under the hood of the Reference processor to cause these results, but this is the most likely culprit for your issue as far as I can tell.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2017 01:56 PM
My jelly is very rusty.. but this works for example:
<g:evaluate var="jvar_userID">
gs.getUserID();
</g:evaluate>
<g:ui_reference name="QUERY:sys_id=${jvar_userID}" id="assigned_to" table="sys_user" />
So in your code:
<g:evaluate var="jvar_userID">
gs.getUserID();
</g:evaluate>
<g:ui_reference class = "beneficiary" name="family_member_1" id="family_member_1" table="hr_beneficiary" completer="AJAXTableCompleter" columns="employee; beneficiary_contact.relationship;" query = "active=true^employee=${jvar_userID}" onChange="beneficiary_1();" />
that should work..
But let me come back with a trimmed version
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2017 02:00 PM
Here is the updated version:
<g:ui_reference class = "beneficiary" name="family_member_1" id="family_member_1" table="hr_beneficiary" completer="AJAXTableCompleter" columns="employee; beneficiary_contact.relationship;" query = "active=true^employee=${gs.getUserID()}" onChange="beneficiary_1();" />
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2017 02:29 PM
Hey Goran, thanks for the thorough answer! Unfortunately your code didn't fix the autocompleter issue. The reference field's query works fine. When I click on the magnifying glass, that beneficiaries list is filtering as intended, but for whatever reason the auto complete drop down in the picture above lists out every beneficiary. Kind of defeats the purpose of having the magnifying glass list being filtered...
Any other suggestions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2017 02:29 PM
If filtering the autocompleter is not possible, do you know of a way to just disable it completely? I'd rather that not show other people's beneficiaries at all.