SharePoint: multiple events for one item updated

I have an item event receiver for a specific type of content that is used in the Pages library. I use the event logger to debug it, and I can say that whenever I edit a page and publish it, it fires 3 ItemUpdating and 3 ItemUpdated . I am sure that no other pages will be saved at this specific time.

What is the reason for this and is there a way to β€œfix” it in order to trigger the publication of only one event on a page?

Alternatively, is there a way to distinguish the last of the events (i.e.: the page is now being published or published) from the others, so I don’t run my code three times?

+4
source share
2 answers

As it turned out, this is because the page was actually saved 3 times when the user clicks "Publish":

  • The document is saved.
  • The document is registered.
  • The document is published.

Each of these triggers has an ItemUpdated and ItemUpdating .

+2
source

Use the DisableEventFiring () method to prevent other events from being triggered. Remember to enable it again with EnableEventFiring (). Hope this helps.

+1
source

All Articles