Using repeats in autocomplete

I’m using Wapplers autocomplete as a search function, which works successfully. However, I am adjusting it so it only shows results from relevant categories that the user searching is added to. I have the server action set up so it only brings the relevant categories:

The issue I am having, however, is that the autocomplete will only return the first result from each query/category in the repeat (Query 0, Result 0 & Query 1, Result 0), instead of all results from each query/category. For the autocomplete data source I have the repeat selected, and the relevant repeat results as the text field.

How can I go about making it so all results are shown, and not just the first in each query? a repeat is not possible on the autocomplete.

Hi,

Autocomplete can have just one array as source of data.
What your screenshot suggests is that you have a repeat which has array inside each of its rows.

So, from what i understand, you need to fix the query in server action to fetch usersearchresults in one query.

You could do a join with projectid table or just use “in” operator in the condition tab.

Hey, thanks.

Could you expand on how to use the in operator for this? I did try join before but didn’t have much luck getting it working.

What I have shared is just ideas on how this could work. For more exact answer, you will have to share some info on how your SA is currently set up.

Sure, so the server action is pretty simple.
image
It first runs a query that fetches which projects a user is added to from one table, the repeat then runs through all the issues that match a project ID that the user is added to in another table. This is then what I am trying to feed to the autocomplete.

Get rid of the repeat here.
Instead, just use the usersearchresults query.
In that, inner join with the project table on user id.
Then, in conditions, add a condition on project id field using in operator and operand as query.groupBy(projectid).keys().

There is also a flatten formatter, but not sure if applicable here. Again, the expression is a rough syntax, hope it makes sense.

Unfortunately, I’m completely confused here.

The first query searches the table AT_usergroup, which contains a userID and ProjectID field. There are multiple entries for one user, depending on how many projects they are added to.

The second query in the repeat fetched all the projectIDs that particular user was added to from the first query, and returned issues across all projects that said user was added to (AT_Issues).

I’ve never used inner joins before, and I tried doing as you suggested but I have no idea what I should be selecting in the “First”, “Operator” and “Second” table options

Got it working! I ended up using one query with an INNER join, making “projectID” from one table match “project” in the other. I then added a Condition that the userID needs to match the user’s identity.

I had no idea the inner join function existed, but this is extremely useful, I’m surprised it isn’t documented anywhere.

Well, it's documented on many places in the internet, example:

This functionality would be documented in Wappler docs most likely. But how inner join works is not in scope of Wappler. Its a SQL thing.

Glad to see you got it working.