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)

Fetch XML Syntex issue

(0) ShareShare
ReportReport
Posted on by 47

Hi 

I wrote a fetch query 

<fetch mapping='logical'>
<entity name='account'>
<all-attributes />
<link-entity name='opportunity' to='accountid' from='customerid'>
<filter type='and'>
<condition attribute="ns_program" operator="eq" value="8887227e-ca21-e611-80e7-c4346bdc0361"/>
</filter>
</link-entity>
<filter type='or'>
<condition attribute="customertypecode" operator="eq" value="717690000"/>
<condition attribute="customertypecode" operator="eq" value="717690001"/>
</filter>
</entity>
</fetch>

But i suspect that results are not as desired. I want to fetch all account record which are connected with opportunities where opportunity.ns_program is '8887227e-ca21-e611-80e7-c4346bdc0361' and account.customertypecode is either 717690000 or 717690000

Can you help to validate if the logic written is correct.

Regards

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    NODAL Profile Picture
    860 on at

    Hi Seema,

    Move filter out of link entity and in link entity put link-type as outer.

    For more troubleshooting use Fetchxml Builder of xrmtoolbox.

    Regards,

    Ketan

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

    Try with this  -

    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
    <entity name="account">
    <attribute name="name" />
    <attribute name="primarycontactid" />
    <attribute name="telephone1" />
    <attribute name="accountid" />
    <order attribute="name" descending="false" />
    <filter type="and">
    <filter type="or">
    <condition attribute="customertypecode" operator="eq" value="717690000" />
    <condition attribute="customertypecode" operator="eq" value="717690000" />
    </filter>
    </filter>
    <link-entity name="opportunity" from="parentaccountid" to="accountid" link-type="inner" alias="ai">
    <filter type="and">
    <condition attribute="ns_program" operator="eq" value="{494FA496-3FF2-E311-9864-A45D36FC5F1C}" />
    </filter>
    </link-entity>
    </entity>
    </fetch>

  • Suggested answer
    Neeraj523 Profile Picture
    on at

    Try this

    <?xml version="1.0" encoding="UTF-8"?>

    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">

      <entity name="account">

         <all-attributes />

          <filter type="and">

            <filter type="or">

               <condition attribute="customertypecode" operator="eq" value="717690000" />

               <condition attribute="customertypecode" operator="eq" value="717690001" />

            </filter>

         </filter>

         <link-entity name="opportunity" from="parentaccountid" to="accountid" link-type="outer" alias="ai">

            <filter type="and">

               <condition attribute="ns_program" operator="eq" value="{494FA496-3FF2-E311-9864-A45D36FC5F1C}" />

            </filter>

         </link-entity>

      </entity>

    </fetch>

  • Seema Gargi Profile Picture
    47 on at

    Thank you for your response Goutam. It as very helpful.

  • Suggested answer
    Seema Gargi Profile Picture
    47 on at

    this worked like a charm. Thank you Neeraj.

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 April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans