What is the difference between the events item:created
vs item:added
? When does each event get hit?
Items are the basic building blocks of your Sitecore website. Items are the basic building blocks of your website. An item can represent any kind of information that makes up a webpage, for example, a piece of text, a media file, a layout, and so on.
Events in Sitecore are similar to events in other systems: handlers subscribe to the event, and when the event is raised, the handlers are called. Many system events in Sitecore are exposed as events that you can subscribe to. It is also possible to add your own events to the system.
Looking at the code of the Sitecore.Data.Events.ItemAddedDelegate you may read that this delegate is deprecated and you should use ItemCreatedDelegate instead. From my tests:
Duplicating item - item:added is NOT executed, only item:created is executed
namespace Sitecore.Data.Events
{
[Obsolete("Use the ItemCreatedDelegate event instead.")]
public delegate void ItemAddedDelegate(object sender, ItemAddedEventArgs args);
}
So in general, always use item:created
The item:added and item:created events seem similar, but Sitecore only fires item:added when a user creates an item through the UI, but it fires fires item:created when code creates items through APIs. Use item:added if you only need to trap manual item additions.
Reference: Taken from John West's blog post
http://www.sitecore.net/learn/blogs/technical-blogs/john-west-sitecore-blog/posts/2011/05/all-about-events-in-the-sitecore-aspnet-cms
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With