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

I'm using event receivers to modify some of the inputs in a SharePoint 2013 site.

They are fairly straight forward, here is a simple example

public override void ItemAdded(SPItemEventProperties properties)
{
    base.ItemAdded(properties);

    using (SPSite site = new SPSite(properties.WebUrl))
    {
        using (SPWeb web = site.OpenWeb(properties.RelativeWebUrl))
        {
            //web.AllowUnsafeUpdates = true;
            SPListItem item = properties.ListItem; // Boom!
            var title = item["Title"].ToString();
            item["Title"] = title.Replace(" ", "_");

            //item.Update();
            //item.SystemUpdate(false);
        }
    }
}

This renders the error

Message:
    Method not found: 'Microsoft.BusinessData.Runtime.IEntityInstance Microsoft.BusinessData.Runtime.NotificationParser.GetChangedEntityInstance(Microsoft.BusinessData.MetadataModel.IEntity, Microsoft.BusinessData.MetadataModel.ILobSystemInstance)'.

Source:
    Microsoft.SharePoint

StackTrace:
   at Microsoft.SharePoint.SPItemEventProperties.get_ListItem()
   at eventreceivers.Kundregister.PrivateCustomer.PrivateCustomer.<>c__DisplayClass2.<ItemAdded>b__0()
   at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass5.<RunWithElevatedPrivileges>b__3()
   at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode)

I have ensured that those methods are available in the class.

Any advices are highly appreciated, thanks!

share|improve this question
add comment

1 Answer 1

I was facing the same issue.

Instead of using

SPListItem item = properties.ListItem;

use following code to get item,

SPListItem item = properties.Web.Lists.TryGetList(properties.ListTitle).GetItemById(properties.ListItemId);
share|improve this answer
add comment

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.