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