Event Handler ItemAdded returns null value

use the following code to get the item from ItemAdded Event.

Public Overrides Sub ItemAdded(ByVal properties As SPItemEventProperties)
Using spsSite As SPSite = New SPSite(properties.WebUrl)
Using spwWeb As SPWeb = spsSite.OpenWeb

Dim iSPl As SPListItem

If spwWeb.GetFile(properties.AfterUrl).Exists Then
iSPl = spwWeb.GetFile(properties.AfterUrl).Item

ElseIf spwWeb.GetFolder(properties.AfterUrl).Exists Then
iSPl = spwWeb.GetFolder(properties.AfterUrl).Item
End If

End Using
End Using
End Sub

This entry was posted in SharePoint and tagged , by Ian Hayse. Bookmark the permalink.

About Ian Hayse

SharePoint Admin. SharePoint Guy. I have been working with SharePoint nonstop for the past six years. In those six years, I've done everything from 'normal' Admin work, development, migrations, training, planning, search, workflow, InfoPath, to crazy fixing of the hands-off SharePoint databases. I'm located in Austin, TX and can always help out with small projects.

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>