I need to verify that an item has an attachment in the ItemAdding event. I've made several attemps to get this to work, but I'm having no luck. Any ideas?
Imports System |
Imports System.Collections.Generic |
Imports System.Text |
Imports Microsoft.SharePoint |
Imports System.Diagnostics |
|
Class ListValidationEventReceiver |
Inherits SPItemEventReceiver |
Public Overloads Overrides Sub ItemAdding(ByVal properties As SPItemEventProperties) |
|
If properties.AfterProperties("AttachmentURL").ToString().Length < 1 Then |
properties.Status = SPEventReceiverStatus.CancelWithError |
properties.ErrorMessage = "You must attach a copy of the invoice to this item" |
properties.Cancel = True |
End If |
|
End Sub |
End Class |