Goal: Upon submission of form, I need to display a "online" icon when a form is connected. If "offline", then display "offline" icon.
Issue: Need help with formula to display "online" or "offline" icon when true or false.
Icon 1 = "icn_NoConnection"
Icon 2 = "icn_Connected"
*Note* = All actions are done through 1 single button "Save"
Solved! Go to Solution.
Thanks for your feedback here. It was helpful. I had some values in the wrong order. However, the icons are still not "showing" or "hiding". What I did was:
At form load, I want form to automatically check if "online" or "offline". Still no luck!
You can't directly set the visibility of a control in that way. You could set a variable then add that variable to the Visible property of the control. Another option is to just have the Visible property of the images check the the connection status.
It would look something like this (Control > Property = Formula):
icn_Connected > Visible = Connection.Connected
icn_NoConnection > Visible = !Connection.Connected
Like @Jeff_Thorpe said, in PowerApps you don't set controls properties by pushing them from an action.
All PowerApps objects (screens, button, label, etc...) have properties
You have 2 kinds of properties :
- Those that trigger an action expecting what we called a "Behavior formula".
For example the OnSelect property of a button expects some actions to be performed when the button is clicked or a screen can perform action when it become visible.
Button.OnSelect : SubmitForm(Form1)
Screen.OnVisible : Set(variable,"this is my variable's value")
- Those that define the control itself expecting a value of a certain type.
For example a the text of a label expect a string or the Visible property of an icon expect a boolean (true or false) to show or not the icon.
Label.text : "here is my label"
Icon.Visible : true (that's means the icon is always visible.
All properties can be defined with logic, so we can defined if a control is visible or not according to some parameters.
As Connection.Connected returns a boolean it can be used directly in a Visible property formula :
Icon.Visible : Connection.Connected
So when the device is connected to internet, Icon.Visible : true so the icon is visible, if no internet Icon.Visible : false and the icon is not visible.
If you wan to display an Icon if there is no connection, the you'll have to use the Not() function (or !)
If no connection Connection.Connected is false, and Not(False) or !false is true. So the icon become visible.
Note that you can use actions to determine a control property, for example I want my icon to be visible if I click on a button.
Screen.OnVisible: Set(iconVisible, false)
Button.OnSelect : Set(iconVisible, true)
Icon.Visible : iconVisible
I've set a variable that is false when arriving on my screen and become true when my button is clicked, and the visible property of my icon is equal to this variable. So the icon become visible only if a click on the button.
Hope it helps understand how properties are set in PowerApps.