cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Gina-PowerApps
Regular Visitor

Offline PowerApps is Patching Blank Entries into Sharepoint List

Hi there, 

 

Wondering if someone can please help - we have built a PowerApp form, (datasource is Sharepoint List) that needs to work whilst flying so have attempted to make it offline capable. Have followed so many different tutorials, I don't even know anymore! 

 

Our app has 1 form based over two screens, we have managed to make this function perfectly online with a 'Collect(listname,collectionname)' submit option. 

 

The idea is that - START navigate(about_you) > About You form - 3 text fields > NEXT navigate(next_screen) > Nomination form - 4 text fields > NEXT Collect(collectname, {columnname:datacard.text}); SaveData(collectionname, "saveditemstokeep"); navigate(pending_screen) > Pending Screen has a SUBMIT Collect(listname,collectionname) and that goes into the Sharepoint list - only works online.

 

The idea is they will close the app and then when they're on the ground can go back in, reload their data and submit when online. Basically, we have managed to get it work - the only part that doesn't is that we can only see a data entry in Sharepoint with blank fields if it was submitted from an offline form. It's almost as if it's not saving the form data and just patching blank fields because there is a row entry for each submission so it's not like it's not patching over at all. 

 

Keep seeing things about having the If Connection.Connected formula on the OnStart or OnVisible first screen but can't figure out what we should put and if this is the reason we're going wrong. 

 

Please help - happy to send screenshots, code, whatever you need.

 

Thanks 🙂

2 ACCEPTED SOLUTIONS

Accepted Solutions
v-jefferni
Community Support
Community Support

Hi @Gina-PowerApps ,

 

Please use below syntax OnSelect of the submit button:

//If it is a one row collection
If(Connection.Connected, 
   Patch(listname,Defaults(listname),{Column1: Column1Value, Column2: Column2Value,... }),
   SaveData(collectionname)
)
//If it is a multi-rows collection
If(Connection.Connected, 
   ForAll(collectionname As C, Patch(listname,Defaults(listname),{Column1: C.Column1Value, Column2: C.Column2Value,... }),
   SaveData(collectionname)
)

 

Please refer to below offline app tutorial doc and follow the steps:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/offline-apps

 

Hope this helps

 

Best regards,

Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

Hi @Gina-PowerApps ,

 

As is an operator function which could help us in complex formulas:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/operators#thisitem-thisrecord...

 

In my reply I just provided two syntaxes based on different cases for you to choose from, "//" generally means comments in various code rules. I think you will have a one row collection created from the two forms, so the first formula is enough to use.

 

For Power Apps offline capability, you will need to understand the logic first. The very important thing is to test the connect status by below function in almost every screen OnVisible or button OnSelect:

If(Connection.Connected, when online the app to execute, when offline the app to execute)

 

In addition, the reason of blank record in SP list is because you are using collect with list as data source but the record in the collection is with a different structure from the list. The proper way to save the collection to the list is using the codes in my reply.

 

Hope this helps.

 

Best regards,

Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.

 

View solution in original post

4 REPLIES 4
v-jefferni
Community Support
Community Support

Hi @Gina-PowerApps ,

 

Please use below syntax OnSelect of the submit button:

//If it is a one row collection
If(Connection.Connected, 
   Patch(listname,Defaults(listname),{Column1: Column1Value, Column2: Column2Value,... }),
   SaveData(collectionname)
)
//If it is a multi-rows collection
If(Connection.Connected, 
   ForAll(collectionname As C, Patch(listname,Defaults(listname),{Column1: C.Column1Value, Column2: C.Column2Value,... }),
   SaveData(collectionname)
)

 

Please refer to below offline app tutorial doc and follow the steps:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/offline-apps

 

Hope this helps

 

Best regards,

Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

Gina-PowerApps
Regular Visitor

Hi, 

 

Thanks for your reply, I appreciate your help. 

 

Sorry I think I'm being stupid but it's not working: 

   ForAll(collectionname As C, Patch(listname,Defaults(listname),{Column1: C.Column1Value, Column2: C.Column2Value,... }),

 What does As C mean? Is that the actual code so ForAll(colItemstokeep As C, Patch(listname,Defaults(listname),{YourName: c.Datacardvalue1, etc} 

 

Do I need a ; in between both those lines because it doesn't seem to like it? 

 

Honestly, all the offline capabilities tutorials are so difficult because they're not just using a simple form from Sharepoint List, so they never work. I think we were the closest to getting it to work but our list just has a row of empty fields. 

 

I've also tried doing something similar to this way: https://blog.atwork.at/post/Working-Offline-with-PowerApps but on that example when I go offline, my form just said "No data source provided". 

 

Will there be a simple solution to offline capabilities coming in the next year? This seems incredibly confusing!  

Hi @Gina-PowerApps ,

 

As is an operator function which could help us in complex formulas:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/operators#thisitem-thisrecord...

 

In my reply I just provided two syntaxes based on different cases for you to choose from, "//" generally means comments in various code rules. I think you will have a one row collection created from the two forms, so the first formula is enough to use.

 

For Power Apps offline capability, you will need to understand the logic first. The very important thing is to test the connect status by below function in almost every screen OnVisible or button OnSelect:

If(Connection.Connected, when online the app to execute, when offline the app to execute)

 

In addition, the reason of blank record in SP list is because you are using collect with list as data source but the record in the collection is with a different structure from the list. The proper way to save the collection to the list is using the codes in my reply.

 

Hope this helps.

 

Best regards,

Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.

 

View solution in original post

Thank you ever so much, that worked! 

 

The next issue we have is that every line is being duplicated now - not so much of an issue as we can remove duplicates in Excel but not too sure why that's happening. I was a bit too worried to put a ClearCollect on startup in case they lose anything entered offline etc. so maybe that's why. 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,330)