Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

A problem with my FetchXML query

$
0
0

I created a FetchXML query using the advanced find, the output of the FetchXML is below. I'm trying to get a record count of the records returned; at the moment I'm getting an error so I'm guessing my query is wrong. I would appreciate if anyone would give me a little direction to fix this.

function DataCheck() {

alert("Function Running");
    var mainTelephone = Xrm.Page.getAttribute("telephone1").getValue();

    var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'> aggregate='true'>";
    fetchXml += " <entity name='account'>";
    fetchXml += " <attribute name='name' />";
    fetchXml += " <attribute name='address1_city' />";
    fetchXml += " <attribute name='telephone1' />";
    fetchXml += "  <attribute name='accountnumber' />";
    fetchXml += "  <attribute name='new_primarypartner' />";
    fetchXml += "  <attribute name='emailaddress1' />";
    fetchXml += "  <attribute name='accountid' />";
    fetchXml += "  <order attribute='name' descending='false' />";
    fetchXml += " <filter type='or'>";
    fetchXml += "    <condition attribute='telephone1' operator='eq' value='02088822222' />";
    fetchXml += "   <condition attribute='new_mobilephone' operator='eq' value='varX' />";
    fetchXml += "   <condition attribute='new_homephone' operator='eq' value='varX' />";
    fetchXml += "   <condition attribute='telephone2' operator='eq' value='varX' />";
    fetchXml += "   <condition attribute='fax' operator='eq' value='varX' />";
    fetchXml += "  <condition attribute='emailaddress1' operator='eq' value='varX' />";
    fetchXml += "  <condition attribute='websiteurl' operator='eq' value='varX' />";
    fetchXml += "  <filter type='and'>";
    fetchXml += "    <condition attribute='new_firstname' operator='eq' value='varX' />";
    fetchXml += "     <condition attribute='new_lastname' operator='eq' value='varX' />";
    fetchXml += "   </filter>";
    fetchXml += "   <condition attribute='address1_line1' operator='eq' value='varX' />";
    fetchXml += "   <condition attribute='address1_city' operator='eq' value='varX' />";
    fetchXml += "   <condition attribute='address1_stateorprovince' operator='eq' value='varX' />";
    fetchXml += "   <condition attribute='address1_postalcode' operator='eq' value='varX' />";
    fetchXml += "  <condition attribute='address1_country' operator='eq' value='varX' />";
    fetchXml += "   <condition attribute='new_dateofbirth' operator='on' value='varX' />";
    fetchXml += "   <condition attribute='new_nationalinsurance' operator='eq' value='varX' />";
    fetchXml += "  </filter>";
    fetchXml += "  </entity>";
    fetchXml += "</fetch>";
    alert(fetchXml);
XrmSvcToolkit.fetch({
            fetchXml: fetchXml,
            async: false,
            successCallback: function (result) {
                var countValue =  result.entities[0].recordcount;
		        //Xrm.Page.getAttribute(countfield).setValue(countValue);
		        alert(countValue);
            },
            errorCallback: function (error) {
                throw error;
            }

});
        
}


Viewing all articles
Browse latest Browse all 8223

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>