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

Notifications

Announcements

No record found.

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 76

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

I have the same question (0)
  • Verified answer
    David Jennaway Profile Picture
    14,065 on at

    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>


  • Clement-ALBERT Profile Picture
    76 on at

    David. Many thanks. Works like magic. Cheers.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans