web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

2011 - Override subgrid fetchXml containing &

(0) ShareShare
ReportReport
Posted on by

I have a javascript web resource overriding the fetchXml based on the company name in the lead entity. When the companyname contains an '&', I receive an error. Does anyone know anything I can do to make this work without throwing an error? The fetchXml is below.

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

       fetchXml += "<entity name='lead'>";

       fetchXml += "<attribute name='ownerid' />";

       fetchXml += "<attribute name='statecode' />";

       fetchXml += "<attribute name='companyname' />";

       fetchXml += "<attribute name='fullname' />";

       fetchXml += "<attribute name='leadid' />";

       fetchXml += "<order attribute='fullname' descending='false' />";

       fetchXml += "<filter type='and'>";

       fetchXml += "<condition attribute='companyname' operator='eq' value='"+companyname+"' />";

       fetchXml += "<condition attribute='leadid' operator='ne' uitype='lead' value='"+leadid+"' />";

       fetchXml += "</filter>";

       fetchXml += "</entity>";

       fetchXml += "</fetch>";

Thanks!

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    jlattimer Profile Picture
    24,562 on at
    RE: 2011 - Override subgrid fetchXml containing &

    Try replacing:

    + companyname +

    With:

    + CrmEncodeDecode.CrmXmlEncode(companyname) +

  • Verified answer
    Community Member Profile Picture
    on at
    RE: 2011 - Override subgrid fetchXml containing &

    All,

    As a follow up, I had to encode the '&' by replacing it with '& a m p ;' without spaces.

    Regards,

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans