Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to Delete all the Related child records from all the related entities with the parent entity.

(0) ShareShare
ReportReport
Posted on by

Hi Friends,

I want to delete all the child records from all the related entities.

For that we have 2 Approaches :

1.Using Cascade Delete

2.Writing a C# Code  using Entity Meta Data.

If i go for the first one using Cascade Delete ,Does it work in the bulk data like if the parent entity has many related child records(Lets say 50k or more).And these 50k records are from all the related entities.

If i go for the 2 one then its taking much more time than i was expecting and the logic is much more complex. 

Please guide me though this scenario so that i could complete it ASAP.

Any help will be highly appreciative.

Thanks

Shashikant Saxena

*This post is locked for comments

  • Community Member Profile Picture
    on at
    RE: How to Delete all the Related child records from all the related entities with the parent entity.

    Thanks for the reply ,this is good approach to opt

    Thanks

    Shashikant Saxena

  • Verified answer
    crm development Profile Picture
    870 on at
    RE: How to Delete all the Related child records from all the related entities with the parent entity.

    Hi, I would suggest you to go with Out of box Bulk delete job to delete parent entity and it will delete all child entity records.

    Another approach would be,

    1) Create bulk delete jobs for different child entities separately (Need to write accurate query in job).

    2) Delete these child entity records first and after these jobs finished, create Bulk delete job for parent entity.

    The advantage in this approach is, while deleting Parent entity records deletion process will be quick as you have already cleared most of the child records. Test thoroughly this approach before implementation.

    Thanks,

    Anand

  • Verified answer
    Kokulan Profile Picture
    18,054 on at
    RE: How to Delete all the Related child records from all the related entities with the parent entity.

    As long as there is a proper parent child relationship and the behaviour is configured for cascade delete the system will delete all the child records.

    You could create bulk delete job with a selected few records in the filter and see if it does what you want to.

    Once its confirmed you can then expand your bulk delete system job query to pickup all the records you intend to delete.

    In your test if it does not delete as you wanted to then we will have to consider other options.

    I would go for out of the box bulk delete first as that does not require any extra effort.

    Please remember that the bulk delete job runs async and it does take time to delete.

  • Community Member Profile Picture
    on at
    RE: How to Delete all the Related child records from all the related entities with the parent entity.

    i just wanna know that sometime cascade delete does not work on the bulk data and records will remain orphan records in the system,Is it true?

    if yes then i should go for the Web Application which is taking much time but feasible.or suggest the alternatives.

  • Community Member Profile Picture
    on at
    RE: How to Delete all the Related child records from all the related entities with the parent entity.

    Like parent entity is "Account" and related Entities could be many.

    So when i delete the Account "A" records (Parent Records), all the records related to "A" will be deleted from the all the related entities if any

  • RaviKashyap Profile Picture
    55,410 Moderator on at
    RE: How to Delete all the Related child records from all the related entities with the parent entity.

    What do you mean by "And these 50k records are from all the related entities."

  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at
    RE: How to Delete all the Related child records from all the related entities with the parent entity.

    Hi Shashikant,

    The first option looks good - Cascade will trigger on bulk delete too!

    Apart from it you can think of migration tools such as Scribe or SSIS to make this happen hassle free.

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