Testing Online Connectivity in PowerApps

This post will walk through testing the Connection.Connected property in your PowerApps.

Connection.Connected

If you are building a PowerApp with offline capabilities, then it becomes very important to test whether the device has an active internet connection. The sensor function Connection.Connected
can be used to test for connectivity – if true, you are connected, false not so much. A common scenario is to check the result of this function in an OnSelect formula. If connected, write or submit to a live data source, if disconnected, write to local collection for submittal later:

While developing your App, it’s somewhat difficult to test this in the web browser in PowerApps Studio, as the Connection.Connected function will usually return TRUE, even if you can’t connect to the internet (unplugged LAN cable, hotel Wifi without accepting terms of use, etc.). Even if you totally disable your network adapters, or put your computer in airplane mode, the property can still be unreliable. Sometimes it reports correctly, sometimes it takes a long time after changing connection status to update in the App, but usually just reports true.

Add to this the fact that if you are disconnected to test offline capabilities, then you can’t really make any changes and Save in PowerApps Studio, because, well, you are disconnected, right?

Fakin’ It

To get around this, you can fake it in the web browser. I call this Force Offline. It’s pretty simple to implement:

  1. Create a new screen, name it Debug, and put a button on it. This will be a hidden screen, since we won’t make any way for a user to navigate to it.
  2. In the button’s OnSelect(), set a global variable:
  3. In the button’s Text property, change the label:
  4. Now, wherever you reference Connection.Connected, wrap it in a check for ForceOffline mode first. Using the earlier example, you’d rewrite it like this:
    OnSelect =

Now, when you want to test, just go to that screen in Edit mode, and Alt + Click the button and put it into Force Offline mode. You can now test away as-if your app is Offline, change it back and test Online, all without having to futz with Airplane mode or disabling/unplugging adapters!

No Comments Permalink

Say something

Your email address will not be published. Required fields are marked with a grey bar.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">