cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rmccook
Frequent Visitor

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
rmccook
Frequent Visitor

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.

View solution in original post

1 REPLY 1
rmccook
Frequent Visitor

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
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (3,326)