Which code segment should you use?

You create an application for a Microsoft Windows SharePoint Services site.

You need to delete all list-scoped alerts that are assigned to a user.

Which code segment should you use?

You create an application for a Microsoft Windows SharePoint Services site.

You need to delete all list-scoped alerts that are assigned to a user.

Which code segment should you use?

A.
Dim site As SPWeb = SPControl.GetContextWeb(context)
Dim users As SPUserCollection = site.Users
For Each user As SPUser In users
Dim alerts As SPAlertCollection = user.Alerts
For Each alert As SPAlert In alerts
alerts.Delete(alert.ID)
Next
Next

B.
Dim site As SPWeb = SPControl.GetContextWeb(context)
Dim users As SPUserCollection = site.Users
For Each user As SPUser In users
Dim alerts As SPAlertCollection = user.Alerts
For Each alert As SPAlert In alerts
If alert.AlertType = SPAlertType. List Then
alerts.Delete(alert.ID)
End If
Next
Next

C.
Dim site As SPWeb = SPControl.GetContextWeb(context)
Dim users As SPUserCollection = site.Users
For Each user As SPUser In users
Dim alerts As SPAlertCollection = user.Alerts
For Each alert As SPAlert In alerts
If alert.AlertType = SPAlertType.Item Then
alerts.Delete(alert.ID)
End If
Next
Next

D.
Dim site As SPWeb = SPControl.GetContextWeb(context)
Dim users As SPUserCollection = site.Users
For Each us er As SPUser In users
Dim alerts As SPAlertCollection = user.Alerts
For Each alert As SPAlert In alerts
If alert.Title = “List” Then
alerts.Delete(alert.ID)
End If
Next
Next



Leave a Reply 0

Your email address will not be published. Required fields are marked *