Your chart component failure involves three interconnected issues that must be resolved together for dashboard rendering to work properly.
Web Resource Dependencies Configuration:
The fundamental problem is how D365 dashboards load web resources. Unlike form scripts that load in sequence with defined dependencies, dashboard web resources load asynchronously in isolated contexts. Your HTML web resource has an implicit dependency on Chart.js, but D365 doesn’t know about this relationship because you’re loading from an external CDN.
First, download Chart.js library and create a new JavaScript web resource:
- Navigate to Settings > Customizations > Customize the System
- Create new Web Resource: new_chartjs.js
- Upload the Chart.js library file (chart.min.js)
- Publish the web resource
Then update your HTML web resource to reference the internal library:
<script src="../WebResources/new_chartjs.js"></script>
<canvas id="salesChart"></canvas>
<script src="../WebResources/new_chartrenderer.js"></script>
Critically, you must declare this dependency explicitly. Open your HTML web resource properties, go to the Dependencies tab, and add new_chartjs.js as a required dependency. This ensures D365 loads Chart.js before your HTML web resource initializes.
Managed Solution Import Requirements:
Your managed solution likely imported the HTML web resource but failed to properly include or link the Chart.js dependency. This is a common issue with managed solutions containing complex web resource hierarchies.
When exporting your solution:
- Ensure ALL web resources are explicitly added to the solution (new_chartjs.js, new_chartrenderer.js, and your HTML resource)
- Verify dependencies are configured BEFORE export - solution export captures dependency metadata
- Check solution XML after export to confirm dependency tags are present
If you’ve already imported a managed solution without proper dependencies, you have two options:
- Export a new version with corrected dependencies and upgrade the managed solution
- Create an unmanaged solution with the missing dependencies (less ideal but works as a patch)
Managed solutions in D365 9.0 have a known issue where web resource dependencies sometimes get stripped during export if the total solution size exceeds certain thresholds. If your Chart.js file is large (>500KB), consider using the minified version or splitting into multiple smaller web resources.
Dashboard Script Support Limitations:
Dashboards in D365 9.0 execute web resources in a restricted security context with several critical limitations:
- No Parent Context Access: Your script cannot access parent.Xrm or window.top - the iframe is completely sandboxed
- Limited API Surface: Only basic JavaScript APIs work; Xrm.WebApi calls will fail unless you use a workaround
- CSP Restrictions: External resource loading (CDNs) is blocked by Content Security Policy
For data retrieval in dashboard charts, you must use alternative approaches:
// Instead of Xrm.WebApi in dashboard context
function fetchChartData() {
// Use XMLHttpRequest with relative URLs
var xhr = new XMLHttpRequest();
xhr.open("GET", "/api/data/v9.0/accounts?$select=revenue");
xhr.setRequestHeader("OData-MaxVersion", "4.0");
xhr.setRequestHeader("OData-Version", "4.0");
xhr.setRequestHeader("Accept", "application/json");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
var data = JSON.parse(xhr.responseText);
renderChart(data.value);
}
};
xhr.send();
}
Also ensure your chart initialization waits for DOM ready state:
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", initializeChart);
} else {
initializeChart();
}
After making these changes - uploading Chart.js as a web resource, configuring dependencies, and updating your managed solution - clear browser cache completely and refresh the dashboard. The chart should render consistently. If it still fails, use browser developer tools to check the Network tab for any 404 errors on web resource requests, which would indicate the dependency chain is still broken.
This draft is based on general Microsoft Dynamics 365 Sales knowledge. It has not been verified against your specific version and environment. Practitioners: verify the steps and share your experience below.