6

What is the best approach to add custom action after the item deleted, such as remove the item Guid from my custom database if that item deleted from Sitecore?

4

You need to implement a custom event handler for item:deleted.

I suggest you patch it from a configuration file and Sitecore will load it for you and execute in this case when the item is deleted. You can read more about with examples here.

The idea in a nutshell is for you to extend the events that get triggered in Sitecore when an action is being executed, in your case the deletion of an item. This works pretty much for other actions as well like item being saved, renamed, moved, etc.

when you patch it and open the showconfig page you will get something like this:

<event name="item:deleted">
    <handler type="Sitecore.Links.ItemEventHandler, Sitecore.Kernel" method="OnItemDeleted"/>
    <handler type="Sitecore.Tasks.ItemEventHandler, Sitecore.Kernel" method="OnItemDeleted"/>
    <handler type="Sitecore.Globalization.ItemEventHandler, Sitecore.Kernel" method="OnItemDeleted"/>
    <handler type="Sitecore.Data.Fields.ItemEventHandler, Sitecore.Kernel" method="OnItemDeleted"/>
    <handler type="Sitecore.Rules.ItemEventHandler, Sitecore.Kernel" method="OnItemDeleted"/>
    <handler type="Sitecore.Caching.Placeholders.PlaceholderCacheManager, Sitecore.Kernel" method="UpdateCaches"/>
    <handler type="YourType, YourAssembly" method="YourMethod"/>
</event>

From there you need to implement YourMethod on YourType with your custom logic

Hope this helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.