When Cloning functionality is used widely throughout the Sitecore solution, it may be necessary to automatically accept changes on the cloned items.
For example, this functionality may be helpful when items are in a workflow. Specifically, in some setups, having to accept changes on cloned item each time a new item version of the source item is created may be considered as excessive actions. You may allow cloned items to be updated automatically instead.
This article provides guidance on how to implement the behavior of automatically accepting changes on the cloned items.
To automatically accept changes on the cloned items, perform the following steps:
public override void AddNotification(Notification notification) { if (this.ShouldAutomaticallyAcceptChanges(notification)) { try { notification.Accept(ItemManager.GetItem(notification.Uri.ItemID, notification.Uri.Language, notification.Uri.Version, Database.GetDatabase(notification.Uri.DatabaseName))); } catch (NullReferenceException ex) { } } else { base.AddNotification(notification); } }
private bool ShouldAutomaticallyAcceptChanges(Notification notification) { //Accepting notifications based on the setting value return Settings.GetBoolSetting("Cloning.AcceptChangesAutomatically", false); //Accepting notifications of the specific type //return notification is VersionAddedNotification; }
<NotificationProvider type="[Fully qualified path to the notification provider class], [assembly containing the class]"> <param connectionStringName="$(id)"> </param> <param desc="databaseName">$(id)</param> </NotificationProvider>
Notes: