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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to make button vis...
Power Apps
Answered

How to make button visible/invisible using if statement

(0) ShareShare
ReportReport
Posted on by 55

Hello everyone. So firstly, here is my code:


If(CountRows(errorGallery.AllItems) < 1,

 

Patch(
Leads,
Defaults(Leads),
{LeadContactName: txtContactName.Text, LeadPhone: txtContactPhone.Text, LeadContactNotes: txtNotes.Text, LeadEntryDate: Date.SelectedDate, AgentEmail: vAgent.AgentEmail, crb4e_lead: Concatenate(txtContactEmail.Text, " -- " , Now())}),

varSubmit && CountRows(errorGallery.AllItems) >= 1 ,

Patch(Leads,Defaults(Leads),{LeadContactName: txtContactName.Text, LeadPhone: txtContactPhone.Text, LeadContactNotes: txtNotes.Text, LeadEntryDate: Date.SelectedDate, AgentEmail: vAgent.AgentEmail, crb4e_lead: Concatenate(txtContactEmail.Text, " -- " , Now())}),

CountRows(errorGallery.AllItems) >= 1, UpdateContext({varResubmit: true});


Set(vReset,true);Set(vReset,false);


UpdateContext({varResubmit: true})
);

 

 

varResubmit is a variable that if true, shows the buttons and data.

 

the first logical, if found true, patch data.

the second logical if found true (variable in button called varSubmit controls main button && count >=1), patch data

 

the third logical if found true, will only show the buttons and data for the user to decide what to do. 

the third one is not working and I need help figuring out why. The app just sits and do nothing when I add the third one.

 

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    156,454 Most Valuable Professional on at

    Hi @sergeasmar97 ,

    I am not sure where varSubmit comes into this as your two Patch statements are the same - is this what you are trying to do (set varResubmit to true of there is anything in the Error gallery)?

    Patch(
     Leads,
     Defaults(Leads),
     {
     LeadContactName: txtContactName.Text, 
     LeadPhone: txtContactPhone.Text, 
     LeadContactNotes: txtNotes.Text, 
     LeadEntryDate: Date.SelectedDate, 
     AgentEmail: vAgent.AgentEmail, 
     crb4e_lead: 
     Concatenate(
     txtContactEmail.Text, 
     " -- " , 
     Now()
     )
     }
    );
    UpdateContext(varResubmit: CountRows(errorGallery.AllItems) > 0}); 
    Set(vReset,true);
    Set(vReset,false)

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • sergeasmar97 Profile Picture
    55 on at

    this works, however, I dont want to patch the data when the CountRows(errorGallery.AllItems) > 0. i only want it to show the gallery and the records, but not add to it as well. what should i modify here?

    UpdateContext(varResubmit: CountRows(errorGallery.AllItems) > 0});

     

  • Verified answer
    WarrenBelz Profile Picture
    156,454 Most Valuable Professional on at

    Hi @sergeasmar97 ,

    Maybe this - I was not sure if your reset at the bottom is also conditional.

    UpdateContext(varResubmit: CountRows(errorGallery.AllItems) > 0}); 
    If(
     !varResubmit,
     Patch(
     Leads,
     Defaults(Leads),
     {
     LeadContactName: txtContactName.Text, 
     LeadPhone: txtContactPhone.Text, 
     LeadContactNotes: txtNotes.Text, 
     LeadEntryDate: Date.SelectedDate, 
     AgentEmail: vAgent.AgentEmail, 
     crb4e_lead: 
     Concatenate(
     txtContactEmail.Text, 
     " -- " , 
     Now()
     )
     }
     )
    );
    Set(vReset,true);
    Set(vReset,false)

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • sergeasmar97 Profile Picture
    55 on at

    thank you!!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 214 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 185

Last 30 days Overall leaderboard