locked
How to deal with & (ampersand) in a fetchXML query? RRS feed

  • Question

  • FetchXML queries don't work when the field has an & (ampersand) symbol, in fact it crashes the javascript code we have. Some Account names have an & in the name (Scott & Co.) so how can we run a FetchXML so that it doesn't crash? Thank you.

    Saturday, June 22, 2013 9:24 PM

All replies

  • Something like this:

    var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>";
    fetchXml += "<entity name='account'>";
    fetchXml += "<attribute name='name' />";
    fetchXml += "<attribute name='primarycontactid' />";
    fetchXml += "<attribute name='telephone1' />";
    fetchXml += "<attribute name='accountid' />";
    fetchXml += "<order attribute='name' descending='false' />";
    fetchXml += "<filter type='and'>";
    fetchXml += "<condition attribute='name' operator='eq' value='Scott &amp; Co.' />";
    fetchXml += "</filter>";
    fetchXml += "</entity>";
    fetchXml += "</fetch>";


    Jason Lattimer
    My Blog -  Follow me on Twitter -  LinkedIn

    Sunday, June 23, 2013 2:24 AM
    Moderator