Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

FetchXML to retrieve Accounts without Contacts, Leads and Opportunities

Posted on by 130

Hi, 

how to generate the fetchxml to retrieve accounts without contacts, leads and Opportunities ?

*This post is locked for comments

  • C. Jensen Profile Picture
    C. Jensen 384 on at
    RE: FetchXML to retrieve Accounts without Contacts, Leads and Opportunities

    Thank you Alex! I did not know that. :-)

  • ashlega Profile Picture
    ashlega 34,475 on at
    RE: FetchXML to retrieve Accounts without Contacts, Leads and Opportunities

    Hi Christian,

    that's a bit of a misconception. You can create that fetch.. see above - it works.. You just can't create such a fetch using advanced find.

    Actually, it's not even my invention:)) Here is the original:

    community.dynamics.com/.../195910
    .

  • C. Jensen Profile Picture
    C. Jensen 384 on at
    RE: FetchXML to retrieve Accounts without Contacts, Leads and Opportunities

    Hi Sateesh

    You cannot retrieve accounts, that does not have child records, with fetchxml.

    What you can do is, create a marketing list that includes accounts which does have these child records. And then you create another marketing list which includes all accounts not present in the first marketing list.

  • Suggested answer
    ashlega Profile Picture
    ashlega 34,475 on at
    RE: FetchXML to retrieve Accounts without Contacts, Leads and Opportunities

    Hi Sateesh,

     you can try this fetch:

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

           <condition entityname="lead" attribute="leadid" operator="null" />

           <condition entityname="contact" attribute="contactid" operator="null" />

           <condition entityname="opportunity" attribute="opportunityid" operator="null" />

         </filter>

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

       </link-entity>

       <link-entity name="contact" from="parentcustomerid" to="accountid" link-type="outer">

       </link-entity>

       <link-entity name="lead" from="parentaccountid" to="accountid" link-type="outer">

       </link-entity>

     </entity>

    </fetch>

  • Emre GULCAN Profile Picture
    Emre GULCAN 2,379 on at
    RE: FetchXML to retrieve Accounts without Contacts, Leads and Opportunities

    Hi Gopalan,

    I might have misunderstood  but he just want get accound datas, he wrote "without contacts, leads, opportunities"

  • Gopalan Bhuvanesh Profile Picture
    Gopalan Bhuvanesh 11,397 on at
    RE: FetchXML to retrieve Accounts without Contacts, Leads and Opportunities

    --

  • Emre GULCAN Profile Picture
    Emre GULCAN 2,379 on at
    RE: FetchXML to retrieve Accounts without Contacts, Leads and Opportunities

    Hi Sateesh,

    You can use "Advanced Find" to get fetchxml.

    Open advanced find > prepare filters and columns > use "download fetchxml" button

    You can also use XrmToolbox 's FetchXML Builder plugin

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,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans