Powerapps Visible function
Asked Answered
P

6

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"

Persephone answered 24/7, 2018 at 13:28 Comment(0)
D
1

Credit @SeaDude

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

Set(mailVisible, !mailVisible)
Dealer answered 10/9, 2020 at 23:49 Comment(1)
Need to mention where mailVisible gets used, the syntax, etc. This answer is incomplete.Saving
M
5

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.

Margotmargrave answered 31/7, 2018 at 3:40 Comment(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.Impower
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.Saving
E
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.

Elegit answered 20/10, 2020 at 19:3 Comment(0)
D
1

Credit @SeaDude

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

Set(mailVisible, !mailVisible)
Dealer answered 10/9, 2020 at 23:49 Comment(1)
Need to mention where mailVisible gets used, the syntax, etc. This answer is incomplete.Saving
G
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.

Grill answered 23/10, 2020 at 14:20 Comment(0)
E
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%.

Equity answered 15/9, 2021 at 6:40 Comment(0)
O
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
Oxalate answered 12/1, 2022 at 9:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.