I’m writing a simple event receiver that executes on itemupdating
, evaluates the value of a single choice column and based on the value and the values of two boolean columns updates another choice column on the same item.
The evaluation works fine but when I save the item I’m getting the following error:
Save Conflict Those conflict with your changes made concurrently by another user. If you want your changes to be applied, click Back in your Web browser, refresh the page, and resubmit your changes.
The receiver code is as follows:
public override void ItemUpdating(SPItemEventProperties properties) { base.ItemUpdating(properties); string OldStatus = properties.ListItem["Status"].ToString(); string CurrentStatus = properties.AfterProperties["Status"].ToString(); string ColumnToUpdate = ""; if (CurrentStatus != OldStatus) { string SomeBooleanColumnValue = properties.AfterProperties["SomeBooleanColumnValue"].ToString(); string SomeotherBooleanColumnValue = properties.AfterProperties["SomeotherBooleanColumnValue"].ToString(); if ((SomeBooleanColumnValue == "True")) { if ((CurrentStatus == "A") || (CurrentStatus == "B") || (CurrentStatus == "C")) { if ((SomeotherBooleanColumnValue == "False")) { ColumnToUpdate = "ValueA"; } else { ColumnToUpdate = "ValueB"; } } else { if ((SomeotherBooleanColumnValue == "False")) { ColumnToUpdate = "ValueC"; } else { ColumnToUpdate = "ValueD"; } } } } this.EventFiringEnabled = false; properties.ListItem["ColumnToUpdate"] = ColumnToUpdate; properties.ListItem.Update(); this.EventFiringEnabled = true; }
All the validations work fine and the variables are set correctly in debug mode. Things I’ve tried so far without solving it:
- Increasing the lookup threshold on the web application (the list item has ~10 lookup columns).
- Instantiating a new SPListItem object and updating it instead of directly working with item.update().
- Using this.EventFiringEnabled = false; before item.update().
Also I’ve made sure that:
- No workflows are running on this list.
- No other event receivers are running on this list.
Any ideas of what else to try to make it work?