What is a good strategy to prevent a change on a parent item in a SharePoint 2010 list if a related child item (i.e. the child of the parent) column is set to open?

For example, I don't want to allow the parent item status column to be set to closed if there are still open child items.

I have written some code that checks if there are open child items but I still cannot show an error message to the end-user and I still cannot prevent the update from being committed. I have tried changing the ItemUpdating to Synchronous execution (from Asynchronous) but it doesn't work.

Currently I can find the open child items but it doesn't seem possible to display an error and stop the execution of the update at this point.

1 Answer 1


Inorder to display error message you need to make few updates in you application web configuration file.

  1. <safeMode> tag should be set as <SafeMode MaxControls="200" CallStack="false" DirectFileDependencies="10" TotalFileDependencies="50" AllowPageLevelTrace="false">

  2. <customErrors mode="On" defaultRedirect="/_layouts/error.aspx" />

Now if validation fails you can use below code in your ItemUpdating event receiver.

properties.ErrorMessage = "Child Items are still Open";
properties.Status = SPEventReceiverStatus.CancelWithError;
properties.Cancel = true;

Also you should note - Event Receivers are executed in a separate process ("OWSTIMER.EXE"). Because of this you won't be able to display the error message on the same Item Edit Page. Instead in case of Error you should redirect the user to a custom error page using web.config entry customErrors

Your Answer

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

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