locked
MSCRM Retrieve N:N related records RRS feed

  • Question

  • Hi,

    I have to retrieve N:N related records using javascript. I am using fetch xml for that but it gives below response:

          <faultstring xml:lang=\"en-En\">Invalid XML.</faultstring>           <ErrorCode>-2147220970</ErrorCode>       <ErrorDetails xmlns:a=\"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: #70CCBB88</Message>

    Is there a limittation that we cannot retrieve n:n through SOAP?

    My fetchxml is like:

    var fetchXml ='<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">'
      '<entity name="a_merit" >'
        '<attribute name="a_meritid" />'
        '<attribute name="a_utcode" />'
        '<order attribute="a_utcode" descending="false" />'
        '<link-entity name="a_ut_a_merit" from="a_meritid" to="a_meritid">'
          '<link-entity name="a_ut" from="a_utid" to="a_utid">'
            '<filter type="and">'
              '<condition attribute="a_utid" operator="eq" value="{'+utid+'}" />'
            '</filter>'
          '</link-entity>'
        '</link-entity>'
      '</entity>'
    '</fetch>'

    I am using SOAP call

    var req = getXMLHttpRequest();
        req.open("POST", _getServerUrl(), async)
        // Responses will return XML. It isn't possible to return JSON.
        req.setRequestHeader("Accept", "application/xml, text/xml, */*");
        req.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
        req.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute");
        req.onreadystatechange = function () { executeSOAPResponse(req, onSuccess, onError); };
        req.send(soapEnvelope);

    I will appreaciate any help here. I have to process thisi fetchxml in javascript.

    I am using ms crm 2013

         
    Friday, August 22, 2014 11:08 AM

Answers

  • Fixed,

    I just missed the + in fetchxml.

    • Marked as answer by Averil Friday, August 22, 2014 12:46 PM
    Friday, August 22, 2014 12:45 PM

All replies

  • N:N relationship retrieval using plugin and linq is very easy but if ur using javascript check this link for an idea http://mscrmmindfire.wordpress.com/2013/12/13/retrieve-nn-relationship-records-using-crmfetchkit/

    Intermediate entity is created for N:N relationships so try retrieving records using odata from that entity.

    Friday, August 22, 2014 12:16 PM
  • Fixed,

    I just missed the + in fetchxml.

    • Marked as answer by Averil Friday, August 22, 2014 12:46 PM
    Friday, August 22, 2014 12:45 PM