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

Offline Forms - Push locally stored data to SharePoint once connected

Hello,

 

I currently have an app that is used to complete forms offline. I am able to store my forms to a collection when offline, but am having trouble sending it to the data source after and clearing the collection. The locally stored forms are located in a gallery and transition to a submitted gallery once pushed to SP. 

 

I use a button to try to push the locally stored data to SP. I shared my code i used to store the collection and the code on my button to push the forms to SP

 

Let me know if you need any more information 

 

Thanks

5 REPLIES 5
TheRobRush
Level 8

Re: Offline Forms - Push locally stored data to SharePoint once connected

What error messages are you getting? Viewing your code I see lots of red, and if the second button (shorter set of code one) is what you are pushing to try and send stuff TO sharepoint I don't see any code in there that would accomplish that.

bubs
Level: Powered On

Re: Offline Forms - Push locally stored data to SharePoint once connected

@TheRobRush 

 

I attached some images of the errors ive been getting. I thought the basis for my code to push data to SP was right. If not do you possibly guide me to fixing it? 

 

thanks

 

sam

 

TheRobRush
Level 8

Re: Offline Forms - Push locally stored data to SharePoint once connected

I'm assuming the image you have loaded named push data to sp is the button you think is sending data into sharepoint (if its mislabeled and im wrong let me know)

Heres what that buttons code is doing

Make collection
Save collection to device (ipad etc)
Update your context
Load the collection from your ipad into powerapps from the save file you just made on device
Update context

I am guessing you thought (load) sent stuff to sharepoint.

To send to sharepoint list you should be using patch.

Not in the office right now so cant really write out a fully fleshed out set of code for your particular app, but if you still need help later on i i will check back in and try and give some more guidance. For now id start with reading through microsofts guide to patch.

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-patch
bubs
Level: Powered On

Re: Offline Forms - Push locally stored data to SharePoint once connected

@TheRobRush 

 

Yeah I have been the code and watching videos i have found to add offline functionality and had a different idea on what the load actually did. I attached my patch function below, the OnSelect for the button that will  patch the selected form to SP. I dont know how I would go about using it if I have like 5 forms saved locally and want to send them all to SP. 

 

I want to be able to have a sync button that will patch all the forms in a collection to SP. I also have headers without data card values  that have an update function in them to collect averages as you can see at the end. I reference a label to each of them to properly store that data. Will a patch be able to send mulitiple forms in a collection at once? 

 

Thank you for the clarification and let me know if I am not clear enough on what I am trying to do and if you need any more details

TheRobRush
Level 8

Re: Offline Forms - Push locally stored data to SharePoint once connected

So anyways theres a couple different ways to handle adding items to a sharepoint list. FIRST the list has to be premade, and you have to use the column names assigned in the list. (Best way to be sure of them is goto list settings (top right gear) then click on each column one at a time, the column reference name will be last part of the web address in the bar above your browser.) I always double check them because sometimes sharepoint inexplicably changes the reference name from what you had set it as. So just to be safe.

 

Couple different ways to add items to the list.

 

 

This one will add a new item to the sharepoint list UBOBoard, THIS METHOD WILL ONLY WORK IF YOUR SHAREPOINT LIST IS NOT EMPTY. On an empty SP List it will throw up an annoying message. I rarely use it because of that.

Collect(UBOBoard, {Title: ThisItem.Title, DATE: DateTimeValue(Label21_2.Text), CURRENTLOCATION:"Upper Lot", HOURSSCHED:Value(shifthrs_2.Text), LOANERINVENUE:false})

This is the most common code I use to add a new row to SP List. This one adds an item to my SPList UBOBoard

Patch(UBOBoard, {Title: ThisItem.Title, DATE: DateTimeValue(Label21.Text), CURRENTLOCATION:"Upper Lot", HOURSSCHED:Value(shifthrs.Text), LOANERINVENUE:false})

 

This one updates a record in the SPList UBOBoard

Patch(UBOBoard, {ID:ThisItem.ID},{DAYSUMMARY:prevassignment & " - " & RoundDown(DateDiff(ThisItem.ASSIGNMENTTIME,DateTimeValue(officialass_1.Text),Minutes),0)&" minutes",ASSIGNMENTTIME:DateTimeValue(officialass_1.Text),CURRENTASSIGNMENT:Text(Radio1_1.Selected.Value)})

Another way to do multiple records at once would be to clearcollect a temporary collection, then add other forms to it via collect

IE)

ClearCollect(TempData, ***ALLTHESTUFFYOUWANT ON THIS COLLECTION);
collect(tempdata,****nextcollectiontoadd);
collect(tempdata,****nextcollectiontoadd)

ETC.

 

then patch your sharepoint list with this collection, or if its not an empty sp list, collect it.

 

 

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 98 members 5,474 guests
Please welcome our newest community members: