have a strange behaviour with alerts on my sharepoint site.
I have a document library where i want to add alerts to specific users when adding,updating,deleting folders or documents. Alerts must not be triggered for a specific user.
ItemReceiver :
public override void ItemAdded(SPItemEventProperties properties)
{
AlertManager manager = new AlertManager(properties.List, properties.Web);
manager.UpdateAlerts();
base.ItemAdded(properties);
}
I have a method where i check if every user of a certain UsersGroup already has an alert or not. If not i add one.
The method which add alerts :
private void CreateUserAlerts(SPUser user)
{
SPAlert newAlert = user.Alerts.Add();
newAlert.Title = "AlertTitle" ;
newAlert.AlertType = SPAlertType.List;
newAlert.List = currentList;
newAlert.DeliveryChannels = SPAlertDeliveryChannels.Email;
newAlert.EventType = SPEventType.All;
newAlert.AlertFrequency = SPAlertFrequency.Immediate;
string userFilter = "userLoginNoTriggerALert";
newAlert.Filter = "<Query><Neq><FieldRef Name=\"Author/New\" /><Value type=\"Text\">" + userFilter + "</Value></Neq></Query>";
newAlert.Update(true);
}
For every first folder/document added the alert is triggered as if the filter isn't taken into account. But then everything work as expected after.
If anyone has an idea.