Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Can someone explain the difference?

Why I want to know:

I needed to use c# to create an alert and assign multiple users to it. I assume that would be SPWeb.Alerts.Add but they both seem to be the same & only take 1 user. In the end I created multiple identical user.alerts, 1 for each a user.

share|improve this question

2 Answers 2

up vote 0 down vote accepted

The only difference between calling SPWeb.Alerts.Add(...) and SPUser.Alerts.Add(...) that in case of SPWeb.Alerts.Add(...) alerts are created for current user.

Otherwise, there is no difference, for example, using the following calls:

web.Alerts.Add(tasks,SPEventType.All, SPAlertFrequency.Immediate);

or

web.CurrentUser.Alerts.Add(tasks, SPEventType.All, SPAlertFrequency.Immediate);

creates the same subscription record in Content DB.

share|improve this answer

There is actually no difference between using SPWeb.Alerts or SPUser.Alerts to add new alerts. They ultimately execute the same code on the backend to create the alert.

When making multiple alerts, you simply need to call one of the methods for each user you are creating the alert for.

share|improve this answer
1  
BTW: You can see what code is being executed on the back-end by opening the Microsoft.SharePoint.dll assembly in .NET Reflector or some other reflector software. Useful when trying to figure out what SharePoint is doing. –  John Chapman Jan 15 '13 at 18:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.