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 / Override visibility wi...
Power Apps
Answered

Override visibility with a button

(0) ShareShare
ReportReport
Posted on by 57

I have a Powerapps form connected to a SharePoint list that includes a single Choice column called Status. When someone attempts to change the status to "Confirmed to Discard" or "Discarded", I want a pop-up to become visible, asking them to confirm if they can discard the samples. I have created a pop-up of sorts within the Status datacard by grouping a rectangle with a label and two buttons. I have set the Group1.Visible to If("Discard" in DataCardValue51.Selected.Value,true). This works as expected.

 

What I would like to have happen is...

- If the person clicks the NO button, I want the pop-up to close and put the Status choice to what it was before they tried one of the options with "Discard".

- If they click the YES button, I want the pop-up to close and accept their change.

 

So the button needs to conditionally override the visibility when YES is selected, otherwise the pop-up remains visible because "Discard" is in the selected value. I think I need to set some sort of variable for the visibility, but I'm new to PowerApps and don't know how to do this. Any advice would be appreciated!

Categories:
  • Verified answer
    LuizVicente Profile Picture
    984 Super User 2024 Season 1 on at

    Well, basically there are a few things to do, for example, what type of variable is best to use for your case, global or context variable.
    Anyway, in my example I use global variable, if it doesn't work for your case, let me know.

    Therefore, in the OnStart property of the App I defined the following variables:

     

    /*
    The gblReset variable is for resetting the option control to its original state, ie, no choice. Strangely, variables that are used to reset a control, Power Apps doesn't seem to take it well, that's why I set the variable first to false and then to true, as the initial state of the control is unselected.
    */
    Set(gblReset, false);
    Set(gblReset, true);
    
    // The gblShowPopUp variable is for defining whether the popup is visible or not.
    Set(gblShowPopUp, false);

     

    In the Reset property of the selection control, place the gblReset variable:

    Roverandom_0-1660614423296.png

     

    In the OnSelect property of the selection control, set the gblShowPopUp variable to true:

    Roverandom_6-1660614903342.png

     

     

    From there, in your popup, set the Visible property to the gblShowPopUp variable:

    Roverandom_3-1660614607566.png

     

    In the OnSelect property of the NO button, set:

    Roverandom_4-1660614654462.png

    Notice that we defined the variables again...

     

    On the Yes button, in the OnSelect property, proceed with what your App should do...

    Roverandom_5-1660614731156.png

     

    Final result:

    showpopup.gif

  • HMP Profile Picture
    57 on at

    Your instructions are excellent, and I was able to replicate what you did. Thank you!

     

    This is on me, as I may not have been clear in my initial post; I'd like the pop-up to appear only if the selected option is "Discarded" or "Confirmed to Discard" (i.e. contains "Discard"). There are many other choices, such as "Processing" and "Analyzing", where I don't need a confirmation pop-up.

     

    As for the last step, where you indicate I should proceed with code telling my App what it should do, all I need it do when "Yes" is selected, is to accept the change, which it appears to do. Does this mean no additional code is needed for the Yes button's OnSelect property?

  • Verified answer
    LuizVicente Profile Picture
    984 Super User 2024 Season 1 on at

    This is on me, as I may not have been clear in my initial post; I'd like the pop-up to appear only if the selected option is "Discarded" or "Confirmed to Discard" (i.e. contains "Discard"). There are many other choices, such as "Processing" and "Analyzing", where I don't need a confirmation pop-up.

     

    Well, in this case you can use a Switch function (in the option's OnSelect property) to test if the selected value contains a word necessary for the popup to appear, or even use the IF function with OR. It would be more or less like this:

     

    Choice.OnSelect:

    // using switch function
    Switch(
     Self.Selected.Value,
     "Selected Value 1",
     Set(gblShowPopUp, true),
     "Selected Value 2", "does nothing",
     // and so on
    )
    
    // using IF with OR function
    If(
     Or(
     Self.Selected.Value = "Selected value 1",
     Self.Selected.Value = "Selected value 3"
     ),
     Set(gblShowPopUp, true),
     "does nothing"
    )

     


    As for the last step, where you indicate I should proceed with code telling my App what it should do, all I need it do when "Yes" is selected, is to accept the change, which it appears to do. Does this mean no additional code is needed for the Yes button's OnSelect property?


    Correct, no additional code is needed in this case.

  • HMP Profile Picture
    57 on at

    This works exactly as needed. Thank you so much! 

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 397 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 354

#3
WarrenBelz Profile Picture

WarrenBelz 232 Most Valuable Professional

Last 30 days Overall leaderboard