cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
DustinB
Advocate I
Advocate I

Patch Collection with LookUp to Dataverse (offline)

Hi everyone,

I'm currently building an App with offline functionality.

 already figured out, how to patch a LookUp field to Dataverse when the data is stored in a collection.

Unfortunately this only works, if the App is online. Does anyone have an idea how to patch the LookUp when the app is offline?

 

Thanks in advance

 

Detailed Situation:

- several Dataverse tables with lookups (1:n)

- the data from Dataverse is stored in collections (via Flow, because of more than 2000 records)

- all LookUp fields are stored via the guid as a text value in the collection

- current Patch function (shorten): 

 

Patch(colQueue, Defaults(colQueue), {Assembly: LookUp(Choices(colQueue.Assembly), Assembly = varSelectedAssembly.Assembly)})

 

- Patch functions works, when the App is online 

- App monitoring revealed that the App uses a few bytes Networktraffic while patching to a collection

- After the first patch in the "offline" Collection, the second patch function will patch the colQueue data to the Queue-Dataversetable

- second Patch function to Dataverse, if the user is online:

 

Patch(Queue, colQueue)

 

 

Does anyone has an idea how to solve my problem? The LookUp and the Choices in the first Patch function are needed, otherwise I'll can't patch the Assembly to the collection, because of a different expected schema for the record. How do I get the lookup choices offline. so the app doesn't need to check them again while patching?

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-jefferni
Community Support
Community Support

Hi @DustinB ,

 

For the first patch, you received the different expected schema error because the LookUp field and Choices field need record. 

 

I assume the varSelectedAssembly is the selected record in a Gallery or a Combo box with items of the Assembly table,  you could modify the formula to below to meet the demand and store the value in the collection:

Patch(colQueue, Defaults(colQueue), {Assembly: varSelectedAssembly}})

 

In the second patch, you will need a forall function:

ForAll(colQueue As Q, Patch(Queue, (Assembly: Q.Assembly)})

 

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

3 REPLIES 3
v-jefferni
Community Support
Community Support

Hi @DustinB ,

 

For the first patch, you received the different expected schema error because the LookUp field and Choices field need record. 

 

I assume the varSelectedAssembly is the selected record in a Gallery or a Combo box with items of the Assembly table,  you could modify the formula to below to meet the demand and store the value in the collection:

Patch(colQueue, Defaults(colQueue), {Assembly: varSelectedAssembly}})

 

In the second patch, you will need a forall function:

ForAll(colQueue As Q, Patch(Queue, (Assembly: Q.Assembly)})

 

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 for trying to help. The different schema error is already solved.
The real problem is that the app doesn't work offline, because of the Choices(colQueue.Assembly) function. 
Although the colQueue collection is saved offline (via SaveData function) the App tries to connect to the dataverse table to get the possible lookup choices... 

Hi @DustinB ,

 

Take the datasource the drop downs are pulling from if it’s not already on the app start and put it into a collection. Then Save that collection so it can be used offline in app start. On the clearcollect on app start where you load that datasource surround by If(connected, data source, load from save file).

 

Please refer to below thread:

https://powerusers.microsoft.com/t5/Building-Power-Apps/Choices-function-with-OptionSet-not-usable-o...

 

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.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

secondImage

Power Apps Community Call

Please join us on Wednesday, October 20th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (2,375)