locked
Getting an error when filter sub grid on account's form RRS feed

  • Question

  • Hi all 

    I have this code

    function filterSubGrid()

    {

       debugger;

       var leadwithSameNameGrid = window.parent.document.getElementById("OrderProduct");

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

       var AccountName = Xrm.Page.getAttribute('name').getValue();

       if (leadwithSameNameGrid == null)

       {

           setTimeout(filterSubGrid, 2000);

           return;

       }

       //fetch xml code

       var contactFetchXML = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"+

    "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"+

      "  <entity name='salesorderdetail'>"+

      "    <attribute name='productid' />"+

      "    <attribute name='priceperunit' />"+

      "    <attribute name='quantity' />"+

      "    <attribute name='manualdiscountamount' />"+

      //"    <attribute name='salesorderdetailid' />"+

      "    <attribute name='extendedamount' />"+

      "    <order attribute='productid' descending='false' />"+

      "    <link-entity name='salesorder' from='salesorderid' to='salesorderid' alias='ay' link-type='inner'>"+

      "      <link-entity name='account' from='accountid' to='customerid' alias='az' link-type='inner'>"+

      "        <filter type='and'>"+

      "          <condition attribute='accountid' operator='eq' uiname='"+AccountName+"' uitype='account' value='"+currentleadId+"' />"+

      "        </filter>"+

      "      </link-entity>"+

      "    </link-entity>"+

      "  </entity>"

    "</fetch>"

      var contactRecords = XrmServiceToolkit.Soap.Fetch(contactFetchXML);

       if (leadwithSameNameGrid.control != null)

       {

           leadwithSameNameGrid.control.SetParameter("fetchXml", contactFetchXML); //set the fetch xml to the sub grid  

           leadwithSameNameGrid.control.refresh(); //refresh the sub grid using the new fetch xml

       }

       else

       {

           setTimeout(filterSubGrid, 2000);

       }

    }

    all my code working fine I have no exceptions in the debugger but my form gives me an error

    The XML passed to th platform is not well formed

    This is the error on my grid

    "Grid refresh failed Please retry" 

    This seem something could happen if I correct some mistake.

    What is wrong. Please help?

    This is my error log file result .

    Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: System.Xml.XmlException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #80B13758Detail: 
    <OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
    <ErrorCode>-2147220970</ErrorCode>
    <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
    <Message>System.Xml.XmlException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #80B13758</Message>
    <Timestamp>2016-08-19T12:11:09.2179179Z</Timestamp>
    <InnerFault>
    <ErrorCode>-2147220991</ErrorCode>
    <ErrorDetails xmlns:d3p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
    <Message>Invalid XML.</Message>
    <Timestamp>2016-08-19T12:11:09.2179179Z</Timestamp>
    <InnerFault>
    <ErrorCode>-2147220970</ErrorCode>
    <ErrorDetails xmlns:d4p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
    <Message>System.Xml.XmlException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #90E8797E</Message>
    <Timestamp>2016-08-19T12:11:09.2189191Z</Timestamp>
    <InnerFault i:nil="true" />
    <TraceText i:nil="true" />
    </InnerFault>
    <TraceText i:nil="true" />
    </InnerFault>
    <TraceText i:nil="true" />
    </OrganizationServiceFault>

    Friday, August 19, 2016 2:34 PM

All replies

  • Hi Abdul,

    I'm facing the same issue. Did you got any solution for it. If yes, please post the resolution steps.

    Thursday, January 12, 2017 12:20 PM
  • Hi,

    Looks like there are two fetch tags defined. Please confirm if it is of typo, else check you code for this. 

       //fetch xml code
       var contactFetchXML = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"+
    "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"+


    Jugal Kishore Dandamudi.

    Monday, January 16, 2017 7:37 AM
  • Hi Jugal,

    Here is my code - I called it on Opportunity Onload. It's working perfectly for most of the opportunity records. I'm seeing weird behavior for only 3-4 opportunities. Tried recreating new account record and associating it with opportunity. Still no luck.

    Help in this regard is highly appreciated.

    ------------------------------------------------------------------------------------------------------

     var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>";
            fetchXml += "<entity name='po_completedcallreport'>";
            fetchXml += "<attribute name='po_completed_accountsoldto'/>";
            fetchXml += "<attribute name='po_company'/>";
            fetchXml += "<attribute name='subject'/>";
            fetchXml += "<attribute name='po_materialgroups'/>";
            fetchXml += "<attribute name='po_reasonforcallvalues'/>";
            fetchXml += "<attribute name='po_dateofcall'/>";
            fetchXml += "<attribute name='ownerid'/>";
            fetchXml += "<attribute name='statuscode'/>";
            fetchXml += "<attribute name='po_completed_summary'/>";

            fetchXml += "<order descending='false' attribute='po_dateofcall'/>";
            fetchXml += "<filter type='and'>";
            fetchXml += "<condition attribute='po_completed_accountsoldto' operator='eq' uiname='" + lookupname + "'  uitype='account'   value='" + lookupid + "' />";
            fetchXml += "</filter>";
            fetchXml += "</entity>";
            fetchXml += "</fetch>";
            if (relatedCallReports.control != null)
     {
                relatedCallReports.control.SetParameter("fetchXml", fetchXml); //set the fetch xml to the sub grid
                relatedCallReports.control.Refresh(); //refresh the sub grid using the new fetch xml
            }
            else{
                setTimeout(updateSubGrid, 2000);
            }

    ------------------------------------------------------------------------------------

    Monday, January 16, 2017 8:52 AM
  • Hello Keerthi,

    Have you tried doing fetch for the opportunity account alone? Did you get the result as expected?

    When you say it is weird only for some accounts, I can suspect that there are no results coming for the fetch.


    Jugal Kishore Dandamudi.

    Monday, January 16, 2017 9:56 AM