cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MichielVanduren
Frequent Visitor

fetchxml query results not in sync

hi,

I have different fetchxml queries in my portal (one added in liquid, one used via an entity view) for which the results should be in sync, but they aren't. I suppose it has to do with caching, the cache is flushed at different moments for these queries.

What can I do about it?

I tried disabling query caching (but this will impact performance) :

To disable caching of the liquid fetchxml, I have added this condition in the query :

<condition attribute="createdon" operator="le" value='{{ now | date: "yyyy-MM-ddTHH:mm:ss" }}' />
How can I do the same in my entity view query, as I can't add liquid syntax to it?
 
thanks

 

11 REPLIES 11
ragavanrajan
Super User
Super User

Hi @MichielVanduren 

 

What you have done is correct for caching. Please check the below blog from @OliverRodrigues

 

https://oliverrodrigues365.com/2020/07/27/power-apps-portals-caching-tips/ 

 

Probably, you can try something with JS or use the OData- JS part. 

 

Hope it helps. 
------------

If you like this post, give it a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users to find it.

eugenevanstaden
Resolver III
Resolver III

@MichielVanduren 

Add the following to your FetchXml - which would break through the cache. For Entity Lists and Forms they should not be affected by cache. Can you enable Change Tracking on the entity?

 

    <filter type="and">
      <condition attribute="createdon" operator="le" value='{{ now | date_add_days: 1 | date: "yyyy-MM-dd HH:mm:ss" }}' />
    </filter>      

 

 

Fubar
Solution Sage
Solution Sage

@MichielVanduren you may be able to do something similar with the view definition - I haven't tried this so do not know it it will work (the reason why the Fetch works is the Query definition is dynamic enough that the definition is not already stored in the cache)image.png

 

@eugenevanstaden the Views on lists are also affected by the Cache and can have a 'lag' when data is updated on the Dataverse side.  Records created/updated outside the Portal e.g. Model Driven App do not push up to the cache synchronously, and the Microsoft SLA on pushing the value up is 15mins (but it normally occurs quicker than that).  Create/Update etc initiated from the Portal and Synchronous processing forming part of those transactions of the direct record are presented to the Portal straight away (but not any indirect records).

eugenevanstaden
Resolver III
Resolver III

@Fubar This i know - but i am not clear if @MichielVanduren making changes through a Web Form - if yes then Cache wont be an issue. 

yes, if making changes to the record from dataverse then cache could be an issue. Change Tracking enabled on the entity should solve that.

@Fubar  @eugenevanstaden @ragavanrajan  thanks for your answers.

The updates on that dataverse entity are done via a plugin.

If we would enable "change tracking" on that entity, I suppose it's not needed anymore to add an extra condition to the fetchxml query?

pswider
Advocate II
Advocate II

@MichielVanduren You said the underlying updates are happening via Plugin. These updates should fire according to how you deployed the Plugin. Perhaps you can get a faster or immediate write to Dataverse by moving the execution stage or setting async options.

Are you familiar with the pipeline execution stages and the options?
https://carldesouza.com/dynamics-365-plugin-execution-pipeline/

https://docs.microsoft.com/en-us/power-apps/developer/data-platform/register-plug-in


Cheers!  Paul

eugenevanstaden
Resolver III
Resolver III

@MichielVanduren 

Are you making changes to related records via Plugin - and this gets executed once you submit a Form from the portal?

If that is the case then execute your changes with PreUpdate or PreCreate plugin step.


@MichielVanduren wrote:

@Fubar  @eugenevanstaden @ragavanrajan  thanks for your answers.

The updates on that dataverse entity are done via a plugin.

If we would enable "change tracking" on that entity, I suppose it's not needed anymore to add an extra condition to the fetchxml query?


@MichielVanduren Change Tracking used to be the old mechanism that was used to push data to the Portal, Microsoft are no longer using this for the Portal and so setting it will not help you any.

MichielVanduren
Frequent Visitor

hi,

I tried turning on "change tracking" for this entity, which didn't worked (like @Fubar already told)

In the view query I added as extra condition : <condition attribute="createdon" operator="last-x-years" value="100" />, which also made no difference.

 

Now we are going to call the webapi in our plugin code, which would invalidate the cache.

Another option would perhaps to use the "organizationservicecontext" in our plugin to invalidate the cache

(see https://www.crmsoftwareblog.com/2012/01/removing-query-data-cached-by-the-organizationservicecontext...)

Helpful resources

Announcements
MPP IDEAS updated 768x460.png

Ideas

Discover ideas and concepts from users like you for how to use Power Pages and take your work to the next level.

Carousel News & Announcements

What's New in the Community?

Check out the latest News & Events in the community!

Users online (3,979)