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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Error Trying to Execute FetchXML in Portal Web Template

(0) ShareShare
ReportReport
Posted on by 70

I am trying to create a custom chart for display in a dashboard in the portal, but I am getting the following error on the portal dashboard: 

[ Liquid error: Exception has been thrown by the target of an invocation. ]

Below is the code in the web template for the dashboard page.  I tried commenting out the code specific to the chart, and the part of the code that triggers the error is the for loop after the end fetch: {% for item in feed.results.entities %}.  Does anyone have any ideas what might be wrong or how to debug this?

...

<div class="col-md-6 hide-chart-legend">
<!-- Opportunities -->
<!--{% chart id:"19A46D6C-82C6-E811-A95D-000D3A3ACDE0" viewid:"1FDF0A3F-856C-E711-8105-E0071B711C21" %}-->
{% fetchxml feed %}
<fetch version="1.0" output-format="xml-platform" mapping="logical" aggregate="true">
<entity name="opportunity">
<attribute name="name" alias="opp_count" aggregate="countcolumn"/>
<attribute name="new_travelyearglobal" />
<attribute name="new_productlineglobal" />
<attribute name="opportunityid" />
<attribute name="new_atacoach" alias="new_atacoach" groupby="true"/>
<filter type="and">
<condition attribute="new_atacoach" operator="eq" value="{{ user.contactid }}" />
</filter>
</entity>
</fetch>
{% endfetchxml %}[
{% for item in feed.results.entities %}
{
"count": "{{ item.opp_count }}",
"owner": " {{ item.new_atacoach.name }}",
"ownerid": "{{ item.new_atacoach.id | escape }}",
"travelyear" : "{{ item.new_travelyearglobal.label }}"
}
{% unless forloop.last %},{% endunless %}
{% endfor -%}
]

<canvas id="opportunityCountByOwnerAndTravelYear"></canvas>
<script src="//cdnjs.cloudfare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script>
<script>
$(function(){
$.ajax({
method: "GET",
url: "/opportunitiesbyownerandtravelyearjson/"
})
.done (function(){
var labels = [], datavalues = [];
for (i = 0; i < results.length; i++)
{
labels.push(results[i].owner);
datavalues.push(parseFloat(results[i].count));
}

var dataobj = {
labels: labels,
datasets: [{
data: countdata
}]
}
});

var ctx = $("#opportunityCountByOwnerAndTravelYear");
var opportunityCountByOwnerAndTravelYear = new Chart(ctx, {
type: 'column',
data: dataobj,
options: {
animation: {
animateScale: true
};
legend: {
display: true,
position: "bottom"
}
}
});

});
</script>
</div>

...

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Dmytro Rutkovskyi Profile Picture
    1,835 on at
    RE: Error Trying to Execute FetchXML in Portal Web Template

    I think the problem itself not Portal related but rather FetchXML related.

    When you group by you can only include the attribute which you are using with groupby keyword or with aggregate function.

    I suggest test fetchXML query independently from the Portal, for example using fetchXML builder plugin of XrmToolbox (https://fxb.xrmtoolbox.com/)

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#2
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans