I have been asked by one of my customers to investigate a problem related to the Liquid Template fetxhxml tag.
If you aren’t familiar with this powerful Liquid tag yet, it allows retrieving Dynamics 365 data using a standard FetchXML query. You can even leverage this tag to retrieve data a-synchronously.
Trying to reproduce the problem, I added a simple FetchXML query within a fetchxml tag in one of the Portal pages via the actual Web Page record, knowing that the front side editor disrupts FetchXML queries syntax.
Testing the query results in the target Portal page, I noticed that the query condition was ignored – the query returned all Contact records.
Returning to the Web Page and refreshing it, I noticed that the FetchXML query mysteriously changed – the closing slash for each attribute element was replaced with a full closing <attribute> tag.
It seems that before saving the Web Page form, the text editor diligently ‘corrects’ my query to comply to XML hierarchy format. This behavior was reproduced with Chrome/Edge browsers on both UII/old forms UI.
Strangely enough, the changed query syntax is considered valid by Dynamics 365, but any query condition is completely ignored.
I am guessing a recent features update changed the text editor behavior, as this behavior does not exist on earlier Dynamics 365 versions.
After searching Microsoft Portal documentation for the fetchxml Liquid Template tag finding no results, I started considering the option that this is not a bug, but maybe some kind of feature phase out. Naaah.
So until Microsoft fixes this glitch, how can you use conditional FetchXML queries and fetchxml liquid tags? By using XrmTookBox Portal Code Editor Plug-in which allows Portal content editing (among other features) without disrupting FetchXML queries
Hi
Just bumped into the same strange behavior…
Another work around is to enclose the liquid FetchXML in html-comment tags i.e.. which causes the CRM html-editor to leave the text as is. 🙂
Liquid doesn’t mind it as it is interpretated regardless of the html-tags and just ends up being an empty comment section in the final Html of the web-page.
Just thought I’d let you know.
Regards Jan