5

For some reason the Visible function in my Powerapps won't work I just wrote in OnSelect() Mail.Visible = false The Mail is in this case a Textinput/ TextBox. When I click on the button nothing happens. I can't find a documentation about it on the MS Website but I have in Powerapps a fuction called "Visible"

Thomas Vangelooven
  • 1,679
  • 2
  • 12
  • 18
Makusium
  • 201
  • 1
  • 2
  • 15

6 Answers6

4

You need to create a variable in the button's (or another control) OnSelect property:

UpdateContext({ mailVisible: false })

And set the Visible property of the Mail control to mailVisible. You may need to initialize that variable to true, for example, in the screen's OnVisible property:

UpdateContext({ mailVisible: true })

PowerApps works similarly to Excel - you cannot, by an action, change directly the value of a cell (e.g., A1 = 42). But you can make the A1 cell reference another cell (say, =A4), so when you change the value of the cell A4, A1 will be updated as well. The same principle applies in PowerApps - you cannot change the value of a property from an action, but you can update the value that the property references.

carlosfigueira
  • 85,035
  • 14
  • 131
  • 171
  • 2
    Some additional functions to consider are: `Set(mailVisible, !mailVisible)` and `UpdateContext({mailVisible: !mailVisible})`. I prefer using `Set()` instead of `UpdateContext()`. Whichever you choose, be sure to stick with the convention throughout your app. Mixing `Set` and `UpdateContext` with the same variable will cause issues. – SeaDude Jul 21 '19 at 17:44
  • Should probably set the variable in the `OnStart` of App instead of `OnVisible` of the screen, because most developers would look at App and not the screen's property when looking for where variables are set. And @SeaDude's comment was spot on and worth a mention, too - that `Set()` and `UpdateContext()` can't be co-mingled. – vapcguy Apr 27 '23 at 22:26
2

So I have a few items like this. I'm not sure if this is the BEST way, but I know it works.

Set a variable on the App's OnStart:

OnStart = Set(variable_visible, "");

Button code:

OnSelect = Set(variable_visible,"1");

Item that you want visible:

Visible = If(variable_visible="1", true, false);

Edit: You can reset your variable at any point to hide that section. Sometimes Power Apps fights you on things that seem correct.

vapcguy
  • 7,097
  • 1
  • 56
  • 52
1

Credit @SeaDude

This worked perfectly for me toggling the variable back and forth to show/hide a few layers.

Set(mailVisible, !mailVisible)
prophoto
  • 342
  • 3
  • 9
0

The Visible will the condition that is true to make it show.

For example

If I have one TextBox named TextInput1 and I want a control to be visible when the Text entered = true it will be. For this example use a label.

Label1's visible function will be TextInput1.Text = "true"

This will show when the input text will be true. if it's false or anything else the label won't show. This is a very basic use of the visible but can be used in many ways.

0

In On select property of button you can't set any other control property directly. you need to follow the steps as:

1- you need to set a boolean type variable on OnSelect of button e.g. Set(varShowMail,false)

2- go to TextInput Mail and select its Visible property and assign the variable "varShowMail"

It will work 100%.

0
  1. Set on visible of screen property UpdateContext({ Var_Visible: false})
  2. set a variable on control "select" or "change" to true"UpdateContext({ Var_Visible: true})" and use the variable in other control visible property that you want to show or hide, if required you can use condition to set a variable to true or false