locked
CRM 2011: FetchXML in JS RRS feed

  • Question

  • Hi,

    I've a JS file which replace existing lookup with custom lookup... Below is the code which is generated through Stunnware and returns results in "Result View" tab on stunnware...

     

    function createLookup() {
     debugger;
     // Set parameters values needed for the creation of a new lookup view...
     var viewId = Xrm.Page.data.entity.getId(); // Using the same GUID, the viewId only has to be unique within each lookup's set of views
     var entityName = "account";
     var viewDisplayName = "Quote Suppliers";
     var viewIsDefault = true;
    
     var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>" +
     "<entity name='account'>" +
    		" <attribute name='accountid' />" +
    		" <attribute name='accountnumber' />" +
    		" <attribute name='customertypecode' />" +
    		" <attribute name='name' />" +
    		" <link-entity name='new_product' from='new_supplier' to='accountid'>" + 
    		"	 <link-entity name='new_quoteproduct' from='new_product' to='new_productid'>" +
    		"		 <filter>" +
    		"			 <condition attribute='new_quote' operator='eq' value='{<Quote GUID>}' />" +
    		"		 </filter>" +
    		"	 </link-entity>" +
    		" </link-entity>" +
    	 "</entity>" +
    "</fetch>"
    ; // Define the appearance of your new lookup view // No changes required here compared to the above, the lookups should have the same appearance var layoutXml = "<grid name='resultset' object='1' jump='name' select='1' icon='1' preview='1'>" + "<row name='result' id='accountid'>" + "<cell name='name' width='200' />" + "<cell name='customertypecode' width='150' />" + "</row>" + "</grid>"; // Add your new view to the Lookup's set of availabe views and make it the default view // The supplier field is specified here, we want to add this view to that lookup field Xrm.Page.getControl("new_supplier").addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, viewIsDefault); }

     

     

    Whereas I am getting error in CRM 2011 as "The XML passed to the platform is not well-formed XML."... Any suggestions?

     


    Ajai

    Friday, April 15, 2011 12:30 PM

All replies

  • BTW, exception log is:-

    Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Invalid XML.Detail: 
    <OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
     <ErrorCode>-2147220991</ErrorCode>
     <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
     <Message>Invalid XML.</Message>
     <Timestamp>2011-04-15T12:23:00.9115178Z</Timestamp>
     <InnerFault>
      <ErrorCode>-2147220970</ErrorCode>
      <ErrorDetails xmlns:d3p1="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: #7BFAEDA5</Message>
      <Timestamp>2011-04-15T12:23:00.9271482Z</Timestamp>
      <InnerFault i:nil="true" />
      <TraceText i:nil="true" />
     </InnerFault>
     <TraceText i:nil="true" />
    </OrganizationServiceFault>
    


    Ajai
    Friday, April 15, 2011 12:34 PM
  • No replies!!!

    Ajai
    Monday, April 18, 2011 9:12 AM