cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Display "Online" Icon when Connection=True

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"

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Anonymous
Not applicable

Re: Display "Online" Icon when Connection=True

Thanks for your input and help @Jeff_Thorpe & @tchin-nin.  This helped tremendously. Figured it out in minutes! 

 

Posting screenshots for others to reference 

 

 

Connected.pngDisplay "Online" icon when ConnectedNotConnected.pngDisplay "Offline" icon when Not Connected.

 

5 REPLIES 5
tchin-nin
Level 10

Re: Display "Online" Icon when Connection=True

Hi,

have you tried

 

icn_Connected.Visible :  Connection.Connected

icn_NoConnection.Visible : !Connection.Connected

 

Théo 

Anonymous
Not applicable

Re: Display "Online" Icon when Connection=True

Hi @tchin-nin,

 

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:

 

  1. On Registration Screen
  2. OnStart = fx = If(Connection.Connected = true, icn_Connected.Visible, icn_NoConnection.Visible)
    1. icn_Connected = !visible (default)
    2. icn_NoConnection = !visible (default)

 Icons_NotVisiblebyDefault.pngOnSelect.png

 

At form load, I want form to automatically check if "online" or "offline".  Still no luck!  Smiley Sad

Super User
Super User

Re: Display "Online" Icon when Connection=True

 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



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly.
If you thought this post was helpful, please give it a Thumbs Up.
tchin-nin
Level 10

Re: Display "Online" Icon when Connection=True

Hi @Anonymous,

 

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 !)
Icon.Visible:!Connection.Connected
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.

 

Théo

  

Highlighted
Anonymous
Not applicable

Re: Display "Online" Icon when Connection=True

Thanks for your input and help @Jeff_Thorpe & @tchin-nin.  This helped tremendously. Figured it out in minutes! 

 

Posting screenshots for others to reference 

 

 

Connected.pngDisplay "Online" icon when ConnectedNotConnected.pngDisplay "Offline" icon when Not Connected.