I added new patch for item:saved event for media add, edit, update and rename in CDN server.

When i am adding new item in media library at that time my custom method OnItemSaved called multiple times (around 5 times).

Is there any provision or option in sitecore to prevent multiple calls?


You did not say, but I imagine you are doing something to the item in your item:saved event, and then you are updating the item. This triggers another saved event, over and over.

What you want to do it check for what you want to change and if the old item and new item match, just return out of the event.

public void OnItemSaved(object sender, EventArgs args)
    // Extract the item from the event Arguments
    Item savedItem = Event.ExtractParameter(args, 0) as Item;

    // Allow only non null items and allow only items from the master database
    if (savedItem != null && savedItem.Database.Name.ToLower() == "master")
        // check for a reason to update, if not just return
        if (savedItem["MyField"] == "reason to update")
            using (new SecurityDisabler())

                // Do your edits here

  • Thanks Chris for your response. But, I am not updating the existing item. I am creating new media item in sitecore at that time item:saved called multiple times. – mitesh patel Jan 8 '19 at 9:40
  • Can you see the item IDs for each of the multi saves? Same item or all different like media center item, then media item, etc... – Chris Auer Jan 8 '19 at 14:00
  • In my scenario, I was publishing the item in this event. At first glance it seemed like the same item firing the event twice, but it was the item in master the first time and the item in web the second time. – Steve Oct 27 '20 at 15:50

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.