Here is the solution for this king of error.
Error code:
public override void ItemAdded(SPItemEventProperties properties)
{
try
{
base.ItemAdded(properties);
base.EventFiringEnabled = false;
SPListItem item = properties.ListItem;
item["ColName1"] = "Value";
item["ColName1"] = "Value";
item.Update(); // Here it throws error
base.EventFiringEnabled = true;
}
catch (Exception ex)
{
throw ex;
}
}
Solution : item.SystemUpdate();
public override void ItemAdded(SPItemEventProperties properties)
{
try
{
base.ItemAdded(properties);
base.EventFiringEnabled = false;
SPListItem item = properties.ListItem;
item["ColName1"] = "Value";
item["ColName1"] = "Value";
item.SystemUpdate();
base.EventFiringEnabled = true;
}
catch (Exception ex)
{
throw ex;
}
}
No comments:
Post a Comment