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

Working Offline

Hi there

I have an application that is running fine whilst online, without any issues. I have put in a set of commands which check to see if I am connected, if I am, I just Patch straight back to CDS (works great), otherwise I store the record in a collection to be saved once connection is restored. One of the columns in the collection is a lookup field, and I save that as a record in the collection. I then have a timer, every 10 seconds checks to see if we have connection established, if the connection is established, I then Patch it back into CDS. As that column is a reference to record, that should save ok, but I get an error "Value must be a data entity record", which it is. So I tried doing a First(Filter(Bookings, booking=bookingId.Booking)), and this saves correctly, but when I look at the data in CDS, that reference is pointing to the wrong booking. Below are the commands: BookingId is set in a Global Variable, and I know it is picking the correct Booking, as I have created a Dubug screen where I can check the contents of an collections or variables.

On Save:

If(Connection.Connected,Patch(Timesheets, Defaults(Timesheets),

{Timestamp: Now(),

Latitude: Location.Latitude,

Longitude: Location.Longitude,

Type: 'Timestamp Type'.'Start of Day',

Instructor: Inst, Booking: First(Filter(Bookings,Booking=bookingRecord.Booking)),

Name: bookingRecord.Name&": " & Text(Now(),"[$-en-GB]dd/mm/yyyy hh:mm") });


ClearCollect(BookingCollection,Filter(Bookings,'Start Time' >= Today() && 'End Time' <= DateAdd(Today(),1) && 'Booking Status' = "Confirmed"));

SaveData(BookingCollection, "bookingsLocalStorage");



Collect(bookingsToBeUpdated,{Timestamp: Now(),

Latitude: Location.Latitude,

Longitude: Location.Longitude,

Type: StartofDayType,

Instructor: Inst,


Name: bookingRecord.Name&": " & Text(Now(),"[$-en-GB]dd/mm/yyyy hh:mm")} );

SaveData(bookingsToBeUpdated, "updBookingsInLocalStorage");



On TimerEnd:

If(Connection.Connected && CountRows(bookingsToBeUpdated) > 0,


ForAll(bookingsToBeUpdated, Patch(Timesheets, Defaults(Timesheets),

{Timestamp: Timestamp,

Latitude: Latitude,

Longitude: Longitude,

Type: Type,

Instructor: Instructor,

Booking: Booking,

Name: Name}));


SaveData(bookingsToBeUpdated, "updBookingsInLocalStorage");


ClearCollect(BookingCollection, Filter(Bookings,'Start Time' >= Today() && 'End Time' <= DateAdd(Today(),1) && 'Booking Status' = "Confirmed"));

SaveData(BookingCollection, "bookingsLocalStorage"))


Any Ideas?


Level: Powered On

Re: Working Offline


Digging a little deeper, when online it works as it is using the connection to CDS, so the reason why it fails when offline is beacuse it is using the collections (local store) to access the booking and instructor, so my question narrows down to - how should I be finding the booking and instructor records from a collection?

Level: Powered On

Re: Working Offline

****Further Update ****

I have left this for the moment as I have many other apps to get on with. It is definitely something to do with how I am retrieving the lookup values from the collection. I have created a debug page where I can view the content of the collections and all the items I expect to have are there. It is very frustrating, but must be something very simple.

Level: Powered On

Re: Working Offline

I would be interested in a solution to this. I am having a similar issue where I am trying to Patch a new record and link it with a related entity. The relationships are already set but PowerApps is displaying some horrendous behaviours where it's been working fine before.

Helpful resources


Power Apps Super User Class of 2020

Check it out!


Power Apps Community User Group Member Badge

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


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


Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Kudoed Authors (Last 30 Days)
Users online (4,889)