{"id":36137,"date":"2019-04-12T12:00:03","date_gmt":"2019-04-12T19:00:03","guid":{"rendered":"http:\/\/devblogs.microsoft.com\/premier-developer\/?p=36137"},"modified":"2019-03-28T10:17:55","modified_gmt":"2019-03-28T17:17:55","slug":"testing-online-connectivity-in-powerapps","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/premier-developer\/testing-online-connectivity-in-powerapps\/","title":{"rendered":"Testing Online Connectivity in PowerApps"},"content":{"rendered":"<p>Premier Developer Consultant <a href=\"https:\/\/www.linkedin.com\/in\/adamtoth\/\" target=\"_blank\" rel=\"noopener\">Adam Toth<\/a> shows you how to test the Connection.Connected property in your PowerApps.<\/p>\n<hr \/>\n<p><span style=\"font-size: 18pt;\">Connection.Connected<\/span><\/p>\n<p>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\ncan be used to test for connectivity \u2013 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:<\/p>\n<pre class=\"lang:default decode:true\">OnSelect = If(Connection.Connected, Patch(Contacts, Defaults(Contacts),{Name:\"Adam\"}), Collect(DraftContacts,{Name:\"Adam\"}))<\/pre>\n<p>While developing your App, it\u2019s 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\u2019t 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<\/p>\n<p>Add to this the fact that if you are disconnected to test offline capabilities, then you can\u2019t really make any changes and Save in PowerApps Studio, because, well, you are disconnected, right?<\/p>\n<p>You can read more of Adam&#8217;s post <a href=\"http:\/\/www.lifeonplanetgroove.com\/testing-online-connectivity-in-powerapps\/\" target=\"_blank\" rel=\"noopener\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post will walk through testing the Connection.Connected property in your PowerApps. 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<br \/>\ncan be used to test for connectivity \u2013 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.<\/p>\n","protected":false},"author":582,"featured_media":36129,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[25],"tags":[4229,24,40,305,3],"class_list":["post-36137","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure","tag-adam-toth","tag-azure","tag-development","tag-powerapps","tag-team"],"acf":[],"blog_post_summary":"<p>This post will walk through testing the Connection.Connected property in your PowerApps. 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<br \/>\ncan be used to test for connectivity \u2013 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.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/posts\/36137","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/users\/582"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/comments?post=36137"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/posts\/36137\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/media\/36129"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/media?parent=36137"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/categories?post=36137"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/tags?post=36137"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}