<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=612681139262614&amp;ev=PageView&amp;noscript=1">
Skip to content

Need help? Talk to an expert: phone(904) 638-5743

Going Offline with Power Apps Import and Export Controls

Going Offline with Power Apps Import and Export Controls

powerappslogoIn my previous post, I showed how to go offline in Power Apps. This post focuses on what happens when you want to close the app and ensure your data is kept. I’ll show you how to use the Import and Export controls to export a file out and import that dataset into an additional app or the same app when you get back online.

My last post showed how you can add records while offline by using collections and then add them into our database/data source once we are back online. Connections has pros and cons; one pro is that it’s easy to implement but the con is if you do a hard shut down of the app on your phone, that collection is lost.

You can use the Import and Export controls in Power Apps to get around this. These controls will let you export a dataset out of Power Apps, using collections or a data source, and import into either the same application or a different one. One use case for this is if I know I’m going to be offline for an extended period and I want to save the state of where I am currently. Another use case is to use this to communicate between applications (export out of one and import into another).

  • My goal is this demo is to take offline mode to another level. I’ll start back in my previous app where I can simulate being offline/online.
  • When I go offline, my data gets written into a collection called colOffline. When I’m online that gets written directly into the database or data source.
  • I’m going to simulate offline and add a few records. Then I’m going to write those by exporting them out, so the records get imported to my database.
  • For most offline capabilities, this will be adequate for your needs when you go offline.
  • But for an instance where you may be offline for an extended period and your app will shut down, we need to do bit more. In this case, we want to export data out and put a file on the phone, typically a JSON file with the data and schema inside of it. The downside to note is as it’s a JSON file, it is clear text so there could be potential for some data leakage. So, this would not be good to have any privacy data (i.e. medical data or credit card info) inside this file.
  • To do this, I’ll first create an export control to take data out. Go to Import from the tool bar and click Media, then Export. Then I’ll create an import control from that Media menu as well.
  • For the export control, I’ll point that data property to my collection (colOffline). Now if I click on the export control button, on my phone it will ask where I want to put this which would be in that JSON file. (This will be a bit different in my video demo as I’m simulating this on my PC, so be sure to check out the video for more detail as well as code information).
  • Next, I’ll click on my import control button, then I’ll use OnSelect to tell it to bring the data in from that file. The code here would be ClearCollect(colOffline, Import2.Data).
  • Now my collections will be fully loaded, and I can switch back online to load those records back in.

So, we can use this to pull back different states of data or you could go out to the middle of nowhere, go offline with your phone with your app closed, do what you need to do with your data and save that file to your phone and then import it back in whenever you’re ready.

If you need Power Apps training, our On-Demand Learning platform has courses covering Power Apps as part of the 55+ library of courses. We can also build apps for you with our Shared Development offering, we can develop the apps you need at a fraction of the cost of hiring a full-time developer. Click the link below to learn more.

Sign-up now and get instant access

Leave a comment

Free Trial

On-demand learning

Most Recent

private training

Hackathons, enterprise training, virtual monitoring