cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
misc
Helper V
Helper V

Hide gallery if User() LookUp returns blank

My app records a staff member's training record, and I want them to be able to come back and edit their record at any time.

 

At the moment, I have a 'Start' button which Navigates a new user to a NewForm, shown in the red box below. This works all good.

newformstart.png

I have a second button which you can see in the bottom left of the screenshot above, which is a Gallery with the Items being:

 

LookUp(MatrixResponses,
User().Email = 'Email Address')

 

This means if a user has already submitted a record it shows that record, and then it navigates to the EditForm. This works by itself too.

My problem is trying to get the Gallery to hide when the lookup returns blank. I have tried a couple of different suggestions noted below, all with no luck.

 

1) Setting visible property of Gallery to:

 

If(IsBlank(LookUp(MatrixResponses,
User().Email = 'Email Address')), false, true)

 

which I believe should mean, if the lookup returns blank (as in, there is no matching email address), do not show the gallery. This returns true however even when the SharePoint list is completely empty

 

2) Setting the visible property of the gallery to:

 

CountRows(Gallery1.AllItems) = 1

 

This is also showing the gallery, even when the SharePoint list is completely empty

 

My plan is to layer the buttons on top of each other, and have the NewForm button visibility set to 

 

If(Gallery1.Visible = true, false, true)

 

so if there is not a previous record the user makes a new one. 

 

Am I missing something obvious? Is there an easier way to do this?

1 ACCEPTED SOLUTION

Accepted Solutions
Pstork1
Dual Super User III
Dual Super User III

IsEmpty works against a string, but Lookup() returns a record.  So your original formula for the visible property will work if you add a string field that will contain a value for each record retrieved.  Title is usually a good choice since it is a simple text field and is required by default.  So your formula should read

If(IsBlank(LookUp(MatrixResponses,
User().Email = 'Email Address').Title), false, true)

I would also save the user's email to a variable onStart and use that instead of the call to user().Email.  Both will work, but getting the user's email once is better than doing it every time the screen is displayed.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

4 REPLIES 4
Pstork1
Dual Super User III
Dual Super User III

IsEmpty works against a string, but Lookup() returns a record.  So your original formula for the visible property will work if you add a string field that will contain a value for each record retrieved.  Title is usually a good choice since it is a simple text field and is required by default.  So your formula should read

If(IsBlank(LookUp(MatrixResponses,
User().Email = 'Email Address').Title), false, true)

I would also save the user's email to a variable onStart and use that instead of the call to user().Email.  Both will work, but getting the user's email once is better than doing it every time the screen is displayed.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

joeinmay
Resolver II
Resolver II

On the visible property of the gallery:

If(IsEmpty(Gallery1.AllItems),false,true)

Thank you - and to @joeinmay  for both your quick responses! It's always those little bits which throw me out 🙂 I ended up going with Pstork1's answer but only because it was the first one I read.

the early bird catches the worm 😁

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

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