cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AndyRossco
Helper II
Helper II

Powerapps Gallery Search with Muliple SQL Linked Tables

Hi,
I am having a problem with the search on gallery, I have 3 tables and I need to search by text values not ID's.
The gallery code is as follows. This is looking at the Notes field, I need to search by either employee name or vanreg.
These values are in 2 other tables, tblEmployee and tblVandetails. These tables hold the unique ID which is stored in the main table tblVanjourneyLog.
SortByColumns(Search([@'[dbo].[tblVanJourneyLog]'], TextSearchBox1.Text, "Notes"), "Notes", If(SortDescending1, Descending, Ascending))
Each field on form has a lookup field as below.
LookUp('[dbo].[Employee]',employee_id = ThisItem.EmployeeID,Concatenate(employee_fname," ",employee_sname))
I need search routine to search by either employee name or vanreg as text not ID's.

See attached table relationships, As you can see the tblVanjourneyLog is main table pulling employee details and van details from related tables.
I need to search or filter gallery by either employee ",Concatenate( employee_fname," ",employee_sname ) or Reg.
Basically when user types in text into search text box it looks for similar text in these fields. So user can type Mike and it finds Mike Morgen etc, Or
He types WA18 and finds anything associated with this reg number.
Alternatively if this is too much , need search box to search by either employee or van reg. using separate search boxes.

Thanks in advance for any help on this

Andy

 

1 ACCEPTED SOLUTION

Accepted Solutions

Sik,

      Thanks so much for your help and patience.

It works now.

 

Kind Regards

Andy😁

View solution in original post

21 REPLIES 21
v-siky-msft
Community Support
Community Support

Hi Sik, Thanks for reply.
Yes I tried your workaround, I have attached screenshots of error messages.
This has really confused me now, not clear how this all works with Var1 etc.

Please advise what next to resolve if possible.

Also can you let me know if you are getting screenshots ok or do you want me to insert into here as pictures.

Kind Regards
Andy

@AndyRossco 

The error shows the variable has been defined as other types in some places.

You can try to change another variable name, and try again.

Sik

Hi Sik,

          Tried setting variable to Var2,Var20 and also VarE still no luck.

How do I check where variables are assigned in App.

Also how does this code work ?

 

Thanks in Advance

Andy

@AndyRossco 

Go to File - Variables -Definitions, you can find all definitions of variable, then check them.

BTW, Have you mixed the Set and UpdateContext functions? You can't use these two functions together to define a variable.

Sik

Sik,
I have attached screenshots of variable errors etc.

@AndyRossco 

That's wired.

Could you try to use this codes to check if there is any error?

Set(Var1,LookUp(Employee,  NameSearchBox.Text in employee_fname & employee_sname ).employee_id)

If it still doesn't work, I suggest you create a new app and try my formula again to check if the error is fixed.

Sik

 

Hi Sik,

           I have edited code and removed second Gallery1.

This has removed some errors as attached screen shots.

However it is not showing all records in application only the first record. I have 3 Records in table.

When I try and search it only returns first record if I leave search box empty. No other records shown ?

 

Code for SORT is using formulae below which has Notes Field, not sure this is correct ?

SortByColumns(Search(Filter([@'[dbo].[tblVanJourneyLog]'], EmployeeID=Var1), NameSearchBox.Text, "Notes"), "Notes", If(SortDescending1, Descending, Ascending))

Also when I look at Var1 in Variables it is showing number 50 which is EmployeeID for Mike Morgan which is correct.

But this is not changing when I search. It reverts to no value unless I search by empty string.

Thanks for your help in advance

 

Andy

Dear Sik,
I have noticed Var1 is retrieving the correct ID when you type in first name.
So this code is good
Set(Var1,LookUp('[dbo].[Employee]', NameSearchBox.Text in employee_fname).employee_id)

The problem is the BrowseGallery1 Items code, this is looking at Notes Column
I have tried changing this with no luck, expects Text value to match NameSearchBox

SortByColumns(Search(Filter([@'[dbo].[tblVanJourneyLog]'], EmployeeID=Var1), NameSearchBox.Text, "Notes"), "Notes", If(SortDescending1, Descending, Ascending))

Helpful resources

Announcements
User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,244)