cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rmccook
Level: Powered On

Load collection to datasource when back online

I have created a collection to store the data entry from my edit form when the connection.connected = false. I would like to load my collection into the datasource when the connection.connected = true. Is there any way to do this?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
rmccook
Level: Powered On

Re: Load collection to datasource when back online

For those of you who are also facing the dreaded task of making an App that is available offline, let me try and help you out a little bit. Before beginning the steps please note that the following solution I did not do any of the below:

 

  1. Displaying items submitted offline in the Detail Screen to users
  2. Updating items submitted offline when offline

The following are the steps I followed to create my form:

  • I created a form from a list on SharePoint
  • The default created forms are the Browse, Detail and Edit screens
  • The Edit screen automatically places a check mark at the top right of the form for submission
  • Select the check mark
  • From Home menu select the first drop down to go to the OnSelect option of the check mark
  • The default formula for the OnSelect action of the check mark field is set to SubmitForm(<name of form>) , in my case it was SubmitForm(EditForm1)
    • What this does is submits the form back to SharePoint which requires an internet connection.
  • To work around this and provide an option for submitting offline, erase the formula from the OnSelect action
  • Start the formula out with the Collect function (https://powerapps.microsoft.com/en-us/tutorials/function-clear-collect-clearcollect/)
    • Example: Collect(TestCollection,{Title: Title!Text})
    • Where TestCollection is any text you want to call the collection
    • Where Title is the name of the column you are adding to the collection. Hint: Keep these the same as your original datasource table headers to make it easier later
    • Where the Title in Title!Text is equivalent to the name of your field on you form. This one got me since I assumed the names of the field would be equivalent to the headers from my datasources table. Unfortunately the names are usually something like DataCard####. So make sure you click on the actual field to get the names or rename the DataCard before doing this.
    • You can add more fields by placing a , at the end of each new field like the following Collect(TestCollection,{Title: Title!Text, Column2: Column2!Text})
    • Note: Use Value for instead of Text after the exclamation point for any numeric fields
  • After your Collect statement add a semi colon so it looks like the following:
    • Collect(TestCollection,{Title: Title!Text, Column2: Column2!Text});
    • (the semi colon pretty much acts as a indicator to move onto a new action)
  • Now that we have our temporary storage collection we'll add an IF statement to check to see if the user has an internet connection or not.
  • Add the following after the semi colon:
    • If(Connection.Connected = true,
  • So now your formula looks like the following:
    • Collect(TestCollection,{Title: Title!Text, Column2: Column2!Text}) ; If(Connection.Connected = true, 
  • Now add Collect('Data Source', TestCollection);
    • Where Data Source is the name of your Data Source for the form
    • Where TestCollection is the name of the collection you created in the first step
  • Finally add the following:
    • Clear(TestCollection);Back(),Back())
    • Where TestCollection is the name of the collection you created in the first step
    • The Back() function takes the user back to the Display screen
    • The Clear function clear the temporary collection so you don't duplicate values when the user get online and submits a new record

You final formula should look something like the folowing:

Collect(TestCollection,{Title: Title!Text, Column2: Column2!Text}) ; If(Connection.Connected = true, Collect('Data Source', TestCollection);Clear(TestCollection);Back(),Back())

 

Hopefully this help a few of you. I wasn't able to figure out how to change my display to show the collection information when offline but it'll work for what I need.

1 REPLY 1
Highlighted
rmccook
Level: Powered On

Re: Load collection to datasource when back online

For those of you who are also facing the dreaded task of making an App that is available offline, let me try and help you out a little bit. Before beginning the steps please note that the following solution I did not do any of the below:

 

  1. Displaying items submitted offline in the Detail Screen to users
  2. Updating items submitted offline when offline

The following are the steps I followed to create my form:

  • I created a form from a list on SharePoint
  • The default created forms are the Browse, Detail and Edit screens
  • The Edit screen automatically places a check mark at the top right of the form for submission
  • Select the check mark
  • From Home menu select the first drop down to go to the OnSelect option of the check mark
  • The default formula for the OnSelect action of the check mark field is set to SubmitForm(<name of form>) , in my case it was SubmitForm(EditForm1)
    • What this does is submits the form back to SharePoint which requires an internet connection.
  • To work around this and provide an option for submitting offline, erase the formula from the OnSelect action
  • Start the formula out with the Collect function (https://powerapps.microsoft.com/en-us/tutorials/function-clear-collect-clearcollect/)
    • Example: Collect(TestCollection,{Title: Title!Text})
    • Where TestCollection is any text you want to call the collection
    • Where Title is the name of the column you are adding to the collection. Hint: Keep these the same as your original datasource table headers to make it easier later
    • Where the Title in Title!Text is equivalent to the name of your field on you form. This one got me since I assumed the names of the field would be equivalent to the headers from my datasources table. Unfortunately the names are usually something like DataCard####. So make sure you click on the actual field to get the names or rename the DataCard before doing this.
    • You can add more fields by placing a , at the end of each new field like the following Collect(TestCollection,{Title: Title!Text, Column2: Column2!Text})
    • Note: Use Value for instead of Text after the exclamation point for any numeric fields
  • After your Collect statement add a semi colon so it looks like the following:
    • Collect(TestCollection,{Title: Title!Text, Column2: Column2!Text});
    • (the semi colon pretty much acts as a indicator to move onto a new action)
  • Now that we have our temporary storage collection we'll add an IF statement to check to see if the user has an internet connection or not.
  • Add the following after the semi colon:
    • If(Connection.Connected = true,
  • So now your formula looks like the following:
    • Collect(TestCollection,{Title: Title!Text, Column2: Column2!Text}) ; If(Connection.Connected = true, 
  • Now add Collect('Data Source', TestCollection);
    • Where Data Source is the name of your Data Source for the form
    • Where TestCollection is the name of the collection you created in the first step
  • Finally add the following:
    • Clear(TestCollection);Back(),Back())
    • Where TestCollection is the name of the collection you created in the first step
    • The Back() function takes the user back to the Display screen
    • The Clear function clear the temporary collection so you don't duplicate values when the user get online and submits a new record

You final formula should look something like the folowing:

Collect(TestCollection,{Title: Title!Text, Column2: Column2!Text}) ; If(Connection.Connected = true, Collect('Data Source', TestCollection);Clear(TestCollection);Back(),Back())

 

Hopefully this help a few of you. I wasn't able to figure out how to change my display to show the collection information when offline but it'll work for what I need.

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, September 18th at 8am PDT

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 260 members 4,473 guests
Recent signins:
Please welcome our newest community members: