cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AVTS
Super User
Super User

Replicate live collection data in to offline collections

Experts,

I'm working on a canvas app to save online data to offline collections.

Following temporary table structure,

 

ClearCollect(TableTempx,{priority: "xx",
        state:    "xx",
        sequence: 0,
        breakdownSymptomGroupCode:"xx" ,
        breakdownSymptomCode:"xx" ,
        shortText: "xx",
        orderNumber: "xx",
        orderClass: "xx",
        customerCode: "xx",
        center: "xx",
        equipmentCode: "xx",
        activityClass: "xx",
        adviceText: "xx",
        orderDate: "xx",
        serviceType: "xx",
        routeId: "xx",
        syncType: "xx"
});

Now i am trying to copy the data from collections(opernorder)  to temporary table Tabletempx with following code,

ForAll(openorder,Patch(TableTempx,
                 Defaults(TableTempx),
{
   
        orderNumber: orderNumber,
        customerCode: customerCode,
         equipmentCode: equipmentCode,
        activityClass: activityClass,
        adviceText: adviceText,
        orderDate: orderDate,
        serviceType: serviceType,
        routeId: routeId,
        syncType: syncType,
                orderClass: orderClass
      
}

)
)

Data is getting copied. But during offline this temporary data is disappearing.  Please guide me to debug the same. 

 

 

 

19 REPLIES 19
AVTS
Super User
Super User

Hi Warren,

 

My requirement is like this. 

 

I have a flow which retrieve data from external database. Flow is assigned to the button click collection.

 

Collect(test1,Getopenorderok.Run("ES001"));

 

I am able to view the collection , Screenshot follows,

AVTS_0-1637061290290.png

 

Now i need to save this data in to offline for further use.  Using following code,

 

SaveData(test1,"TableTempx1");

LoadData(test1,"TableTempx1",true);

 

As i said in previous message i am unable to show or view this offline (TableTempx1) data anywhere. 

 

How can i achieve this. 

 

 

 

HI @AVTS ,

I am a bit lost here - if you run in a new session on the same device

LoadData(test1,"TableTempx1",true);

after previously running in the last session

SaveData(test1,"TableTempx1");

you should have the same collection test1 as you saved before. Are you saying the data was not saved/retrieved?

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

 

Yes waren.

Flow data saved in Collection name as test1. And and saving the test1 data to offline collection name as TableTempx1.

 

I do know how to confirm the data availability(not saved/retrieved) status ..

There is no way to verify the current saved/retrieved status.  There is also no way to view the offline data in its stored state. The only way to verify that data was retrieved is to clear the collection and LoadData.  If after that the collection has rows then the data was retrieved.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
AVTS
Super User
Super User

Hi @Pstork1 thank you for your response . Below is the revised on . is this correct way .  Please advise.

 

SaveData(TableTempx1,"test1");  ------- Copying the collection from "test1" and save it in cache table " TableTempx1"

 

Clearcollect(TableTempx1,"test1")  -----retrieved is to clear the collection and LoadData

 

 

 

 

 

 

 

Not quite.  You can't load the collection from offline storage using ClearCollect.  You want the following;

SaveData(TableTempx1,"test1");  ------- Save the Collection to test1
Clear(TableTempx1)  -----Delete the TableTempx1 collection contents
SaveData(TableTempx1,"test1")  ---- Reload TableTempx1 from saved data


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Hi @AVTS ,

What I posted previously - 

What have you got to verify it against? It involves a bit of trust in the process I think.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

Dear @WarrenBelz ,

 

This is my application requirement.

Every morning, download the sales data from the web database and store it to the local database. In offline mode, you may also work with local database data. Offline sales data may be edited and saved. In the evening, transfer the data from the offline database to the online database.

I chose offline because there is little network connectivity in this region of the world. It is why we have to utilize the app with a local database.

 

Hope i have answered your question. 

@AVTS ,

I am not sure how to add to my response. Unless you save it twice to two offline storages and compare them (then they both may contain the same error/omission). This is more a QA question than a coding item - the device will read whatever is stored in its offline storage when opening the app and then store the changed data back at whatever period or process you have written in it. This overwrites any previously stored data. If I have missed something here, please tell me what it is you want to validate the data against.

maybe changing terminology will clarify things a bit more.  When you add data to a collection, that is an Offline database.  LoadData and SaveData are like doing a local Backup.  Backups aren't directly addressable as databases.  Some backup systems have a process for validating the contents of a backup.  Power Apps does not have such a facility.  So a collection is offline (local storage) of the database.  It will persist as long as the app isn't closed.  If the app is closed then LoadData will restore the local collection without an online connection.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,476)