1

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 1

2
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.

3
  • 1
    Thank-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
  • 2
    It should be added in the ItemUpdating event receiver to have any effect. Sep 9, 2014 at 5:09
  • 2
    Yes. Sorry. It should be itemUpdating. Sep 9, 2014 at 5:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.