Search and autofill in text box based on list values
We are all used to web searches giving suggestions of possible values you want and Combo Boxes have a Search function, but Text inputs do not have anything built-in for this, so it should be useful to have this function as well.
In the example below, the user starts typing and all matching values come up below. At any time they can press Enter and have the first (or only) matching value populate automatically in the Text Box.
The process involves only three things - changes to the OnChange and Default of the Text box and a Label below. This example is from a test list I have, but will work on any list subject to size Delegation on the Distinct function in the Label (I am sure there are work-arounds if this is an issue). Firstly, the OnChange of the example Text Box (txtManName) is
With(
{
_Match:
If(
!IsBlank(Self.Text),
LookUp(
Devices,
StartsWith(
ManufacturerName,
Self.Text
)
).ManufacturerName
)
},
UpdateContext(
{
varMatch:
Coalesce(
_Match,
Self.Text
)
}
)
)
So a Variable is being updated to the first matching value (if present) in the list or if not present the existing text. The Default of the Text box is
varMatch
If this is being used in a form to also display existing records, you would add
Coalesce(
varMatch,
Parent.Default
)
and also reset varMatch at Screen OnVisible and possibly on Form submit.
UpdateContext({varMatch: Blank())
The last bit is the Label Text
If(
!IsBlank(txtManName.Text),
Concat(
Distinct(
Filter(
Devices,
StartsWith(
ManufacturerName,
txtManName.Text
)
),
ManufacturerName
),
Value,
", "
)
)
I hope this is useful for you as an alternative to using a Combo Box
Comments
-
Search and autofill in text box based on list values
Sorry not something fitting the structure here.
-
Search and autofill in text box based on list values
Hi @WarrenBelz I used this functions above and everything worked fine as long as I already have a list item matching the name I want to use and just selecting the matching search. But how about if I would in my form like to add a new item? I only get an error message "The second argument to function LEFT is invalid": Can you help me solving this?
-
Search and autofill in text box based on list values
Hi @WarrenBelz ,
I have a table in Excel and I used your above formulas. I changed "ManufacturerName" to Description (this is the title of the column I need it to search in) and I changed "Devices" to Inventory (this is the name of my table). I changed txtManName to TextInput8. When I run the app it does not pull up the names I have in the description column. If I type an A in the text box, an A pops up in the label box and nothing else happens. I also copied those formulas to different cards on a Scollable Screen and when I enter text into 1 box, all the boxes show the same value. Any tips?
*This post is locked for comments