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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

"Invalid XML" error

(0) ShareShare
ReportReport
Posted on by 297

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

I have the same question (0)
  • Verified answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    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.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    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>";


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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
AS-17030037-0 Profile Picture

AS-17030037-0 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans