cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
misc
Resolver II
Resolver II

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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (26,422)