Showing results for 
Search instead for 
Did you mean: 
Level: Power Up

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: Power Up

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: Power Up

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


PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.


Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.


Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020


Power Platform World Tour

Coming to a city near you


PowerApps Community User Group Member Badge

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


Join PowerApps User Group!!

Connect, share, and learn with your peers year-round


Power Platform Summit North America

Register by September 5 to save $200

Users Online
Currently online: 416 members 4,963 guests
Please welcome our newest community members: