Belangrijke mededeling over deze pagina:

Deze pagina is niet beschikbaar in het Nederlands en daarom wordt de Engelse versie van het artikel getoond. Dit komt vooral voor bij technische artikelen.

This is just a quick blog-post about temporarily disabling local events through the Sitecore API.

When writing your code you might come to a point where you for example calling a method which finally result in triggering a (custom) Sitecore event.
For example, the Item.Editing.EndEdit() method.
This method contains an overload which contains a param: EndEdit(bool silent)

Setting this param to true results in calling the ItemManager.SaveItem method inside this using clause:

using (new EventDisabler())
{
  ItemManager.SaveItem();
}

Looking at this code, it is also possible to use the using clause at other positions in your code where you have the need to temporarily disable the events that normally will be triggered.

using (new EventDisabler())
{
  // Your custom code without temprarily triggering events
}

Plaats een reactie