Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

"Invalid XML" error

Posted on by 295

Hello Everyone!

I have created an activity in which there is a fetchXml query so my activity rurns successfully in same case and in some cases throws "Invalid XML" exception. Kindly tell me what i do? Following is query .

string recordsFetchQuery = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>
                      <entity name='usnw_researchaccountmapping'>
                        <attribute name='usnw_researchaccountmappingid' />
                        <attribute name='usnw_researchaccountant' />
                        <order attribute='usnw_researchaccountant' descending='false' />
                        <link-entity name='usnw_usnw_department_usnw_researchaccountmap' from='usnw_researchaccountmappingid' to='usnw_researchaccountmappingid' visible='false' intersect='true'>
                          <link-entity name='usnw_department' from='usnw_departmentid' to='usnw_departmentid' alias='ac'>
                            <filter type='and'>
                              <condition attribute='usnw_name' operator='eq' value='"+departmentReference.Name+@"' />
                            </filter>
                          </link-entity>
                        </link-entity>
                      </entity>
                    </fetch>";

*This post is locked for comments

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: "Invalid XML" error

    Try with this  -

                              string recordsFetchQuery = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>"
                                                        + "<entity name='usnw_researchaccountmapping'>"
                                                        + "<attribute name='usnw_researchaccountmappingid' />"
                                                        + "<attribute name='usnw_researchaccountant' />"
                                                        + "<order attribute='usnw_researchaccountant' descending='false' />"
                                                        + "<link-entity name='usnw_usnw_department_usnw_researchaccountmap' from='usnw_researchaccountmappingid' to='usnw_researchaccountmappingid' visible='false' intersect='true'>"
                                                          + "<link-entity name='usnw_department' from='usnw_departmentid' to='usnw_departmentid' alias='ac'>"
                                                            + "<filter type='and'>"
                                                              + "<condition attribute='usnw_name' operator='eq' value='" + departmentReference.Name + "'/>"
                                                            + "</filter>"
                                                          + "</link-entity>"
                                                        + "</link-entity>"
                                                        + "</entity>"
                                                        +"</fetch>";


  • Verified answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: "Invalid XML" error

    Hi,

    If this is working in some case but in some case it is giving Invalid XMl then it must be because for soem records you are gettign some spscial characters withnthe name field hence the generated xml is corrupted.

    Check this below article to handle this: www.inogic.com/.../how-to-handle-special-characters-in-fetch-xml

    Hope this helps.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,104 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans