I have a list with requests. This list is monitored by BizzTalk and synced with an external system.

In the list is a status column, which is hidden on the editing/new form, in which the status of the request is stored ('Pending', 'Accepted', ' Denied', 'Cancelled').

The user who file request must be able to alter and delete requests. When a request is new/updated I can set the status to 'Pending' using the itemUpdating/itemAdding events.

I would like to archive the same when a user tries to delete a request (using the itemDeleting event). The request shouldn't be deleted but has its status changed to 'Cancelled'.

How do I set a property in the deleting event and at the same time cancel the deletion of the item?

I tried:

properties.Cancel = true;
properties.Status = SPEventReceiverStatus.Continue;
properties.AfterProperties["GE_AO_Status"] = "Vervallen";

That results in an error that the afterproperties can't be changed in this event.

(using MOSS SP2)

edit I changed my code to (thanks Gomiunik and Cimares):

SPListItem item = properties.ListItem;
item["GE_AO_Status"] = "Vervallen"; 

and it works. Both answer have more complicated ways of getting the ListItem, why?

2 Answers 2


You can't alter the AfterProperties as they're going to be cancelled.

What you can could try however is instantiate another copy of the item IE using the List object from the properties and then running GetItemByID(properties.item.ID) and then set the properties on that. You might have to use SystemUpdate() to force it through, and also make sure you turn off event firing.

You'll need to test what happens to the cancel event and make sure it finishes cleanly, but I'd have a look at that option.


  • Why not use SPListItem item = properties.ListItem?
    – Dribbel
    Mar 15, 2012 at 9:43
  • You probably could do, but I'd test it. I was erring on the side of caution by completely re-instantiating a new SPListItem object.
    – Cimares
    Mar 15, 2012 at 12:58
  1. Make sure you're not having base.ItemDeleting(properties) after your code.
  2. in properties you also have 'properties.ListItem' so what you could do after you cancel is as follows

    SPListItem itm = properties.ListItem.ParentWeb.Lists[properties.ListId].GetItemById(properties.ListItemId); itm["GE_AO_Status"] = "Vervallen"; itm.Update()

Not exactly sure if all proeprties and method naming is exact, but you can rely on intellisense to help.

  • Why not use SPListItem item = properties.ListItem?
    – Dribbel
    Mar 15, 2012 at 9:43
  • In some cases properties.ListItem can give you a save conflict.
    – Gomiunik
    Apr 23, 2012 at 22:58

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.