cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jzcase
Resolver II
Resolver II

Retrieving up-to-date collections after patching new records--32 second lag?

Has anybody else experienced a lag in their canvas apps' ability to pull recently added records in Dataverse in a ClearCollect?

 

I have two instances in my app where I Patch() a new record in a table called "CASE Service" and attempt to update the local collection myStudents from the same table. In both instances, it takes roughly 32 seconds before ClearCollect() results in the new record getting captured.

One way I could maybe get around this would be to not use ClearCollect to re-pull all data from Dataverse, but instead, Set() a global variable NewService to the Patch() function, and then Collect() that record into the existing myStudents collection. 

 

However, myStudents and "CASE Services" are not identical tables. ClearCollect(myStudents) uses ShowColumns() and AddColumns() to create a single collection with columns from 4 different Dataverse tables. So this workaround with be difficult.

1 ACCEPTED SOLUTION

Accepted Solutions
jzcase
Resolver II
Resolver II

Hi all,

 

I solved this and wanted to share my method.

 

Using @C-Papa 's suggestion, my script for patching Dataverse also patches the local collections with the exact same data. In fact I went around the app and used a similar method for every interface that updates Dataverse--instead of asking Dataverse for a refreshed copy of the data, it just updates both datasets in parallel.

 

This results in a much faster and more responsive app, not to mention fewer API calls, so it's pretty great! However it does add complexity and more places for things to break.

 

Also one important note: @C-Papa you said that Patch() doesn't return the Dataverse GUID for the new record, but you actually can get it by using Set(newRecord, Patch(dataverseTable, Defaults(dataverseTable),{Fields and stuff}))

 

Then you can reference newRecord.dataverseTableGUID and it will correspond to what is in dataverse.

View solution in original post

3 REPLIES 3
C-Papa
Responsive Resident
Responsive Resident

Hi, i would use an edit form, set its textinputs to have the desired answer in them, either from other input fields or gallery selected items, i would change the edit form .visible to false. Then on your onselect of your button have something like this:

 

SubmitForm(Form1)

 

on Form1 on success property add:

 

Patch(myStudents,Form1.lastsubmitted);ResetForm(Form1)

 

The main issue when you patch a new record is it doesn't return the ID number, so even though you are patching the same data the unique ID field will not match for the same record in both collections until the data is clearcollected again from the data source. 


I'm not sure if I can just do Patch(myStudents,Form1.lastsubmitted) because myStudents is not identical to its source table "CASE Services".

 

I use ShowColumns() and AddColumns() in the ClearCollect(myStudents,"CASE Services") so the result is that myStudents's columns are different even though some of the data is the same. E.g., the column names have been changed to their schema names.

 

Would it be more like the following?

 

Patch(

myStudents,

Defaults(myStudents),

{case_Service: Form1.lastsubmitted.Student},            // GUID

{case_ServiceType: Form1.lastsubmitted.'Service Type'}  // Choice field (example)

{other fields}

)

jzcase
Resolver II
Resolver II

Hi all,

 

I solved this and wanted to share my method.

 

Using @C-Papa 's suggestion, my script for patching Dataverse also patches the local collections with the exact same data. In fact I went around the app and used a similar method for every interface that updates Dataverse--instead of asking Dataverse for a refreshed copy of the data, it just updates both datasets in parallel.

 

This results in a much faster and more responsive app, not to mention fewer API calls, so it's pretty great! However it does add complexity and more places for things to break.

 

Also one important note: @C-Papa you said that Patch() doesn't return the Dataverse GUID for the new record, but you actually can get it by using Set(newRecord, Patch(dataverseTable, Defaults(dataverseTable),{Fields and stuff}))

 

Then you can reference newRecord.dataverseTableGUID and it will correspond to what is in dataverse.

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (52,973)