Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Joshua Weber 11 posts 112 karma points
    Apr 21, 2022 @ 12:29
    Joshua Weber
    0

    Delete Child Nodes programmatically

    Hey Umbraco Community,

    I am currently facing the Issue of having a few thousand child nodes, that have been created on a certain date, I need to delete. I know it sounds a bit insane, but it is not possible for me to delete all of these by hand since opening the parent node in the Webinterface hangs all of my browsers. I started with an approach to first get all the Child nodes which works perfectly but I simply cannot find a mention in the API documentation on how to delete a node.

    Is there even a way to do this?

    Best regards,

    Josh

  • Tom Madden 252 posts 454 karma points MVP 3x c-trib
    Apr 21, 2022 @ 19:17
    Tom Madden
    100

    Hi, you can change to view the children in List View by selecting this for the parent doctype, then change the 'List View - Content' data type to display, saw 100 records at a time, then you can select all 100 records at a time and delete them in batches. I wouldn't delete many more than that at a time or you'll probably get timeouts.

    You can also delete nodes using the ContentService if you prefer to do this programmatically, but I'd also do this in batches of no more than 100-200 at a time or you'll probably bring the site down. ContentService docs (for v8) are here: https://our.umbraco.com/apidocs/v8/csharp/api/Umbraco.Core.Services.IContentService.html

    HTH

    t

  • Joshua Weber 11 posts 112 karma points
    Apr 22, 2022 @ 08:22
    Joshua Weber
    0

    Thank you very much for your helpful answer. This truly helps. <3

    I will use the List view approach as it is really the easiest way :)

Please Sign in or register to post replies

Write your reply to:

Draft