I have some code in an event receiver in ItemUpdated that checks for duplicates when an item is updated. I would like to if the item already exists after the changes, the updates are not applied. How do I do this?
1 Answer
properties.Status = SPEventReceiverStatus.CancelWithError;
properties.ErrorMessage = "Custom Error Message";
properties.Cancel = true;
Place these 3 lines in a logical block which needs to stop the execution in the item updating event receiver. It will show the custom error message and stop updating.
-
1Thank-you, but this does not work in my solution. It hits this code (I set breakpoints) but nothing is triggered. Sep 9, 2014 at 4:17
-
2It should be added in the ItemUpdating event receiver to have any effect. Sep 9, 2014 at 5:09
-
2