web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Liquid Template - Caching FetchXML?

(0) ShareShare
ReportReport
Posted on by

Hi

I am building a custom web temlpate in Dynamics Portal but it looks as though the FetchXML is caching.  Is there any way to ensure that a page load always pulls an updated FetchXML response?

Thanks

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Kokulan Profile Picture
    18,054 on at

    Hi

    You could generate random cache string to invalidate the FetchXML cache, please see below

    ScreenClip-_5B00_437_5D00_.png

    https://stoneridgesoftware.com/using-liquid-templates-and-fetchxml-to-retrieve-data-in-a-dynamics-365-online-portal/

  • Community Member Profile Picture
    on at

    I like the idea!  For some reason it doesn't make a difference.

    I am posting form submissions back to the same page, and am using javascript to make sure that the cache string updates each time but I'm still not getting an updated view.  It's always a submission behind.

  • Suggested answer
    oliver.rodrigues Profile Picture
    4,052 on at

    I am doing a similar approach, but instead of a random string I am filtering by a timestamp.. also I am assuming your entity properties is checked with the option "Change Tracking" right?

    {% assign currentDate = now | date: "yyyyMMddHHmmss" %}
    {% assign conditionCache = '<condition attribute="name" operator="ne" value="' | append: currentDate | append: '" />' %}
    
    {% fetchxml query %}
    <fetch mapping='logical' version='1.0'>
        <entity name='YOUR ENTITY'>
            <filter type='and'>
            <condition attribute='statecode' operator='eq' value='0' />
            {{ conditionCache }}
            </filter>
        </entity>
    </fetch>
    {% endfetchxml %}


  • Community Member Profile Picture
    on at

    Thanks, but I still can't get this to work.  My fetchxml is touching three entities, and all of them have Change Tracking checked.  I've added the conditionCache to each of the entities but it still doesn't load the next item fast enough.  Could it be that the page load in portals is simply happening faster than CRM can update with a newly inserted record?

    {% fetchxml my_query_b %}

    <fetch version="1.0" mapping="logical">

     <entity name="contact">

       <attribute name="firstname" />

       <attribute name="lastname" />

       <attribute name="sc_skatecanadaid" />

    <order attribute="lastname" descending="false" />

       <link-entity name="sc_clubprogrammember" from="sc_contact" to="contactid" link-type="inner" alias="ab">

         <filter type="and">

           {{ conditionCacheProgram }}

         </filter>

         <link-entity name="sc_clubprogram" from="sc_clubprogramid" to="sc_clubprogram" link-type="inner" alias="ac">

           <filter type="and">

             <condition attribute="sc_clubprogramid" operator="eq" uitype="sc_clubprogram" value="{{ classId }}" />

             {{ conditionCacheProgram }}

           </filter>

         </link-entity>

       </link-entity>

       <filter type="and">

         {{ conditionCacheContact }}

       </filter>

     </entity>

    </fetch>

    {% endfetchxml %}

  • Community Member Profile Picture
    on at

    I have fixed the issue.  As well as using the method above, I have also set the form submission to redirect to the same page on success.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans