4

I have an item event receiver for a specific content type that is used in a Pages library. I am using the event logger to debug it, and I can tell that whenever I edit a page and publish it, it fires 3 ItemUpdating and 3 ItemUpdated events. I am certain that no other pages are being saved in that specific time.

What is the cause of this and is there any way to "fix" it to trigger only 1 event per page publish?

Alternatively, is there any way to distinguish the last of the events (ie: page is now published or being published) from the others, so I don't end up running my code three times?

Christian P.
  • 4,784
  • 7
  • 53
  • 70

2 Answers2

2

As it turns out, it was because the page was actually being saved 3 times when a user clicks "Publish":

  1. The document is saved.
  2. The document is checked in.
  3. The document is published.

Each of these triggers an ItemUpdated and ItemUpdating event.

Christian P.
  • 4,784
  • 7
  • 53
  • 70
1

Use the DisableEventFiring() method to prevent any other events from firing. Just remember to enable it again via EnableEventFiring(). Hope this helps.

Skippy
  • 56
  • 2