London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!
AI OnAI Off
London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!
No there's isn't one. However, you can easily set one up using ContentEvents in CMS with very minimal code.
[ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
public class ChangeEventInitialization : IInitializableModule
{
var oldFieldValue = "";
public void Initialize(InitializationEngine context)
{
var events = ServiceLocator.Current.GetInstance<IContentEvents>();
events.PublishingContent += Events_PublishingContent;
}
private void Events_PublishingContent(object sender, EPiServer.ContentEventArgs e)
{
// Fetch the currently published version
var contentLoader = ServiceLocator.Current.GetInstance<IContentLoader>();
var publishedVersionOfPage = contentLoader.Get<IContent>(e.Content.ContentLink);
// You can then do something like if (e.Content is SitePageData pageData) to get the pageData/contentData for pages/blocks to get the new value
// Compare old with new and send email accordingly (use try/catch and other techniques based on requirements)
}
public void Uninitialize(InitializationEngine context)
{
var events = ServiceLocator.Current.GetInstance<IContentEvents>();
events.PublishingContent -= Events_PublishingContent;
}
}
My goal is to set up a notification service via email that notifies subscribers when a particular field has changed in the CMS. Is there any hook for this already, e.g., diffing field values?