CRM 2011 JS: Insert FetchXml into subgrid chart's view using javascript

I went digging around on the net to find examples of this and did find serveral that got me in the right direction.  But I still seem to be missing something.  I think what I'm doing wrong is assigning the fetchxml to the subgrid rather than the chart's view in the subgrid.  Can anyone tell me how to fix this?  Thanks for all your help!

Here is the error message, not very helpful...

 

code:

function UpdateSubGrid() {

    var accountSales = document.getElementById("SalesSummary");

    if (accountSales.readyState != "complete") {

        setTimeout('UpdateSubGrid()', 1000);

        return;

    }

    var accID = Xrm.Page.data.entity.getId();

    alert(accID);

    var accountNum = Xrm.Page.getAttribute("jensen_accountnumber").getValue();

    var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>";

    fetchXml += " <entity name='account'>";

    fetchXml += " <attribute name='jensen_yeartodatesales' />";

    fetchXml += " <attribute name='jensen_yeartodateplan' />";

    fetchXml += " <attribute name='jensen_lastyearsales' />";

    fetchXml += " <attribute name='name' />";

    fetchXml += " <filter type='and'>";

    fetchXml += " <condition attribute='statecode' operator='eq' value='0' />";

    fetchXml += " <condition attribute='accountnumber' operator='eq' value='";

    fetchXml += accountNum;

    fetchXml += "' />";

    fetchXml += " </filter>";

    fetchXml += " <order attribute='name' descending='false' />";

    fetchXml += " </entity></fetch>";

    alert(fetchXml);

    accountSales.control.setParameter("fetchXml", fetchXml);

    accountSales.control.refresh();

}

 

 

Here is the Account form with the subgrid that has the chart in it, highlighted:

This chart us showing ALL accounts rather than being filter to the account I'm in.  The new fetchXml that I'm trying to assign it did not get set.

Posted by Cory Bonallo