2
votes

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"

5

5 Answers

4
votes

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.

1
votes

Credit @SeaDude

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

Set(mailVisible, !mailVisible)
0
votes

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 start:

App = Set(variable_visable, "");

Button code:

Onselect = Set(variable_visable.,"1");

Item that you want visible:

Visibility = If(variable_visable="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.

0
votes

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
votes

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%.