Page Type save event.

 

Hi, 

I'd like to implement some additional CMS auditing to record when any changes are made to a page type by a user within the CMS (Such as adding a new property, or removing an existing property).

I was hoping that there would be an event or something similar that I can hook into but am having trouble identifying anything suitable.

Has anyone accomplished a similar thing?

Thanks.

#194797
Jul 03, 2018 15:00
Per Gunsarfs
Member since: 2005
 

Hi

I haven't tested this myself but there two static events on ContentTypeRepository (ContentTypeSaved and ContentTypeDeleted), that I think you should be able to use to handle this scenario.

Regards

Per Gunsarfs

#194800
Jul 03, 2018 15:20
 

Hi,

Thanks for your reply. Can confirm the below logic works.

      protected void Application_Start()
        {
            ContentTypeRepository.ContentTypeSaved += (sender,eventArgs) =>
            {
                // Logic here
            };
        }
#194805
Jul 03, 2018 16:02
Marija Jemuovic
Member since: 2010
 

Hey Luke,

Just a small side-note. You should rather use an initialization module to subscribe to events. Read more https://world.episerver.com/documentation/developer-guides/CMS/initialization/ 

They will get re-executed in case of an exception + you can add dependencies. A very similar example to yours: https://world.episerver.com/documentation/developer-guides/CMS/initialization/Creating-an-initialization-module/ 

BR,
Marija

#194915
Jul 08, 2018 15:44
This topic is created over 6 months ago and already resolved. If you have similar question please create new topic and refer to this one.