Hi I have a question. I need to develop an apps that can be used while offline.
When internet isnt available, the data is stored in collection, but is it possible to edit the data stored in the collection before it sync back to cds when internet is available?
Yes, it is possible to edit the data stored in a collection before it syncs back to CDS. Here's a pseudocode example
When the internet is not available you can save data to the local storage
If(Connection.Connected,
some code to update your datasource;
SaveData(your_collection_name, your_local_storage_name))
When the internet is not available you could load data from local storage.
If(Connection.Connected,
ClearCollect(your_collection_name, your_datasource_name);
LoadData(your_collection_name, your_local_storage_name, true))
---
Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."
So lets say if I just created an order while offline, and then I want to edit the details first before sync back to cds.is it possible?
I can't say I know much on CDS so let's see what @cwebb365 has to say on that one...
While doing some of my own research today I came across a fantasic article that discussed offline mode at length. I found it very useful, you might too... https://jobs.collab365.community/powerapps-offline-disconnected-mode/
I haven't done this with CDS, but with SharePoint and SQL my approach was:
When making a changes to the records in a collection, save them to the same local collection, but usethe modified date as a flag (with Sharepoint use the built in modified date field, in SQL create a modified date field that defaults to the current date).
Anything without a modified date is a new record.
When deleting a record set the modified date to an arbitaty date that is in the past (e.g. 1 Jan 2000)
When modifiying an existing record, set the modified date to a different arbitrary date in the past (e.g. 1 Jan 2001)
You can then build a sync routine that does the following:
Filter on Blank modified date and insert those records
Filter on modified date = 1 Jan 2001 and perform a ForAll and Patch the changes (if using SQL set the modified date to Now())
Filter on modified date = 1 Jan 2000 and delete those records
Finally, repopulate (clearcollect) your local collections from the data in your datasource
Ensure that after every change, deletion, insert, you do a SaveDate. Repopulate your collections with a LoadData when the App opens. Whenever using a local collection in the App remember to filter out records where modified date indicates they are deleted.
Note that this assumes that any change made by your App should 'win' in any conflict (e.g. a conflicting change is made in the datasource before the App next syncs its changes). You could build some logic around this but it would be very complex.
User | Count |
---|---|
262 | |
110 | |
89 | |
54 | |
44 |