I am trying to get the notifications on a clone after I change the source item. In our system, when the source item changes, the clone automatically changes as well. However we need to auto-reject the Sitecore notification that says, "A field in the original item has been changed" and gives the review/accept/reject options. The problem is that using GetNotifications() on the clone returns 0 elements - meaning Sitecore didn't find any notifications. However I clearly see them when I reload/re-open the clone.
I tried reloading the item using:
item.Reload();
and
Context.ClientPage.SendMessage(this, "item:load(id=" + item.ID + ")");
before running GetNotifications(), but neither made the count of notifications greater than zero.
Here is my full code used (where copyItem is my clone) int k is a test and it returns 0.
using (new SecurityDisabler())
{
if (copyItem.IsClone)
{
var notifies = Database.GetDatabase("master").NotificationProvider.GetNotifications(copyItem);
int k = -1;
if (notifies != null) k = notifies.Count();
foreach (Notification n in notifies)
{
n.Reject(copyItem);
}
}
}
Note: I'm calling the above code underneath the OnItemSaved event.