Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

FetchXML for "BulK Delete Job"

(0) ShareShare
ReportReport
Posted on by 72

Hello Techies,

We are currently in a CRM 2015 on-premises environment.
I'm tyring to implement a "bulk delete task" with the following FetchXML

<fetch distinct="false" no-lock="false" mapping="logical" >
    <entity name="contact" >
        <attribute name="fullname" />
        <attribute name="telephone1" />
        <attribute name="emailaddress1" />
        <attribute name="address1_city" />
        <attribute name="bdf_numbstreet" />
        <attribute name="bdf_birthplace" />
        <attribute name="bdf_birthdate" />
        <attribute name="address1_postalcode" />
        <attribute name="telephone2" />
        <attribute name="contactid" />
        <filter type="and" >
            <condition attribute="lastname" operator="like" value="%Tiers Demandeur%" />
            <condition attribute="bdf_ishiddendemande" operator="eq" value="0" />
            <condition attribute="bdf_isdeclareastd" operator="eq" value="0" />
            <condition attribute="bdf_isanonymouscontact" operator="eq" value="0" />
            <condition attribute="bdf_ishiddenrdv" operator="eq" value="0" />
            <condition attribute="bdf_isrl" operator="eq" value="0" />
        </filter>
        <link-entity name="serviceappointment" from="bdf_pris_par_personne_physique" to="contactid" alias="appointment" link-type="outer" >
            <filter>
                <condition attribute="bdf_pris_par_personne_physique" operator="null" />
            </filter>
            <attribute name="bdf_pris_par_personne_physique" />
        </link-entity>
        <link-entity name="incident" from="bdf_tiers_demandeur_personne_physique" to="contactid" alias="incident" link-type="outer" >
            <filter>
                <condition attribute="bdf_tiers_demandeur_personne_physique" operator="null" />
            </filter>
            <attribute name="bdf_tiers_demandeur_personne_physique" />
        </link-entity>
        <order attribute="fullname" descending="false" />
    </entity>
</fetch>
 

I'm trying to get the contacts that DONT figure in the "bdf_tiers_demandeur_personne_physique" column of the "Incident" entity and
the "bdf_pris_par_personne_physique" colum of the "serviceappointment" enity. The columns are lookups to the "contact" entity.

What changes should I make to EXCLUDE the contacts who are refrenced in the lookup columns of the "Incident(bdf_tiers_demandeur_personne_physique ) / serviceappointment (bdf_pris_par_personne_physique)".

Awaiting your valuable inputs.

Regards,
Clément

 

*This post is locked for comments

  • Clement-ALBERT Profile Picture
    72 on at
    RE: FetchXML for "BulK Delete Job"

    David. Many thanks. Works like magic. Cheers.

  • Verified answer
    David Jennaway Profile Picture
    14,065 on at
    RE: FetchXML for "BulK Delete Job"

    You need to move the condition clauses under the filter for the contact entity, and to add an entityname attribute that links to the alias of the link-entity. There's also no need to include the attribute element in each link-entity, as these will never contain data.

    <fetch distinct="false" no-lock="false" mapping="logical" >
        <entity name="contact" >
            <attribute name="fullname" />
            <attribute name="telephone1" />
            <attribute name="emailaddress1" />
            <attribute name="address1_city" />
            <attribute name="bdf_numbstreet" />
            <attribute name="bdf_birthplace" />
            <attribute name="bdf_birthdate" />
            <attribute name="address1_postalcode" />
            <attribute name="telephone2" />
            <attribute name="contactid" />
            <filter type="and" >
                <condition attribute="lastname" operator="like" value="%Tiers Demandeur%" />
                <condition attribute="bdf_ishiddendemande" operator="eq" value="0" />
                <condition attribute="bdf_isdeclareastd" operator="eq" value="0" />
                <condition attribute="bdf_isanonymouscontact" operator="eq" value="0" />
                <condition attribute="bdf_ishiddenrdv" operator="eq" value="0" />
                <condition attribute="bdf_isrl" operator="eq" value="0" />
                <condition entityname="appointment" attribute="bdf_pris_par_personne_physique" operator="null" />
                <condition entityname="incident" attribute="bdf_tiers_demandeur_personne_physique" operator="null" />
            </filter>
            <link-entity name="serviceappointment" from="bdf_pris_par_personne_physique" to="contactid" alias="appointment" link-type="outer" >
            </link-entity>
            <link-entity name="incident" from="bdf_tiers_demandeur_personne_physique" to="contactid" alias="incident" link-type="outer" >
            </link-entity>
            <order attribute="fullname" descending="false" />
        </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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 54

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans