web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / how to hide create but...
Power Apps
Answered

how to hide create button based up on gallery content

(0) ShareShare
ReportReport
Posted on by 397

I was try this with regular text box, check and uncheck box and it is working fine.

 

However if try to hide and unhide a "create new button" based up on the Gallery items, it is not working at all. 

 

My scenario is that- I have a a screen with Gallery filtered based up on the "assigned to" column. If user already submitted a line item through the form then it should not allow them to create one more request when they land on that screen. And if the user never created a request through that form then "create new button" should show up for that user. 

Categories:
I have the same question (0)
  • myke_deabreu Profile Picture
    220 on at

    Hi Rajkumar88,

     

    You could do this on the Visible control of the button:

     

    CountRows(Filter(Gallery2.AllItems,column with user=username))<1

     

    That just says if the gallery row count is lower than 1 where the user is filtered. If its true the number shows else if false number is hidden.

     

    Let me know if this doesnt work. 

     

     

  • rajkumar88 Profile Picture
    397 on at
    Thanks for your quick reply. I think above solution will work. However what if it is a manager - and his/her gallery has pending, approved items already available because of thier employee created but manager never submitted one request of thier own. In this case filter less than 1 doesn’t work right? Then the filter should created by manager is true then disable the button and if not emable the button? Can you please provide ansample code?
  • myke_deabreu Profile Picture
    220 on at

    So If I understand correctly there are two "modes".

     

    One where people create and one where people approve?

  • rajkumar88 Profile Picture
    397 on at

    yes that's true. And the second mode where people approve should also be able to create a request by clicking that button. however it should be visibal eonly if that person haven't created it earlier. 

  • myke_deabreu Profile Picture
    220 on at

    So if you use the logic :

     

    CountRows(Filter(Gallery2.AllItems,column with user=username))<1

     

    This will hide the button if someone has created an item. 

     

    For the Approve button you can have a list either on sharepoint or with a collection within the app to be visible if name in list.

     

    so on approve button visible formula you could have "username in list"

  • rajkumar88 Profile Picture
    397 on at

    sorry I didn't understand properly. Sorry I am bit new to this. 

     

    for first scenario: if user is an employee, then below solution works fine, because this user is not required to approve anything. Thanks for sharing it.
    CountRows(Filter(BrowseGallery1.AllItems,Assigned=User().Email))<1

     

    Second Scenario: Here it will be manager, and once manager lands on "browsescreen" → Gallery1, will have all the pending and approved items for the manager to approve them. However manager should also complete his request as if this is not completed earlier. Below attached is the screen shot which are pending for the manager to provide comments. however he/she never requested one for themselves.  so Do i Need to add filter to exclude pending tasks and then allow him to create new request if not created already? 

    Capture.PNG

  • myke_deabreu Profile Picture
    220 on at

    How does the manager approve? I dont see a button.

     

    The formula in scenario one will only work if the user created a record. if the manager didnt create one the button will be visible.

  • rajkumar88 Profile Picture
    397 on at

    thanks again for your reply. Please find the screen shot below. I created one seperate screen for "EMPLOYEEE" and one screen for "Manager only" Below screen for manager. I am trying to filter pending requets as well as created by himself request. I am not able to get ending requests in this code.

     

    2. "new survey" button for "visible" property I am using CountRows(Filter(Gallery2.AllItems,'Created By'.DisplayName=User().Email))<1  . Am I using the right way?

     

    Note: This is all for Manager screen now. Employee screen is different and it is working fine as per your code. thanks a lot for that.

    powerapps.PNG

  • myke_deabreu Profile Picture
    220 on at

    Three things:

     

    First:

    I would set the users email to a varible on the "OnStart" option of the app as it is "best practices" to limit calls in an app it helps it perform better. (See Screenshot). Remember to right Click the "App" icon and click "run Onstart" to run it after you make any changes to the formula. Basically when the user starts the app anything in that formula will run.

     

    Second:

    In your formula you are saying 'Created By'.DisplayName=User().Email. It should be 'Created By'.Email.

    If you do what I mentioned in step one you will do 'Created By'.Email=var_useremail.

     

    Third:

    I personallly dont like using the 'Created By' column to filter as it has a bunch of data in it. If you want to use email as a filter I would create an "Email" column and when the user patches just patch the email to that column and use it to filter. ##You dont have to do this just something I have done as I feel filtering using 'Created By' is slower.

     

    Hope this helps.

  • rajkumar88 Profile Picture
    397 on at

    Thanks for your sugegstion. That's a good idea. Howwever onstart -- I already have a rule as per below line.

     

    If(User().Email in EmailList.ManagerEmail,Navigate(ManagerLandingscreen,ScreenTransition.None),User().Email in EmailList.EmployeeEmail, Navigate(EmpLandingScreen, ScreenTransition.None))

     

    How can I add your code there? sorry to ask dumb question as I am pretty new to in PowerApps development.

     

    Also as per the previous reply, I am using a filter based up on Created By'.DisplayName=User().Email to display gallery items. But do know how can I make it work if I click on Pending then it should show only pending items, if I click all it should show only all. somthing like that possible?

     

    3. with respect to third point, how can I patch user email to the "email column" ? is it needs to be done before they save the request or on the start screen get the user email address and update the column?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard