I want to update a SP boolean column on an ItemAdding event receiver. I want to set the "Hide physical URLs from search" column (PublishingIsFurlPage) to Yes.

My code look like this :

  public override void ItemAdding(SPItemEventProperties properties)
     EventFiringEnabled = false;

     properties.AfterProperties["PublishingIsFurlPage"] = "1";

     EventFiringEnabled = true;


It does nothing event if I used "True", "TRUE", true instead of "1".

Anyone have an idea how to set this boolean column ?


2 Answers 2


Using AfterProperties is generally not the approach I go with, since it's often buggy/not behaving the way we expect (see for instance Working with BeforeProperties and AfterProperties on SPItemEventReceiver).

First thing, why do you use ItemAdding? In your case, wouldn't ItemAdded -in an asynchronous ER- be more suited?

In an ItemAdded, I'd then have no problem to run this code:

base.EventFiringEnabled = false;
SPListItem item = properties.ListItem;
item["PublishingIsFurlPage"] = true;
base.EventFiringEnabled = true;

If you want to continue on with ItemAdding, here are two things to check:

  1. For a Yes/No field, assign the boolean true, not the string "1", "True" or anything else.
  2. Be sure you use the internal name of the field.
  • Thanks. I already try your solution in ItemAdded but I've always got the The file Pages/sss.aspx has been modified by SHAREPOINT\system. Very frustrating. Any idea ? When I do not trace the ItemAdded, I don't have this erreur but the boolean is not even set.
    – user41391
    Apr 14, 2015 at 15:55
  • There may be another ER linked to your list. This is a publishing page in the Pages doc lib? Or the page may be created, your ER triggers, but at the same time the page is checked-out for editing... For a test, you can try to get a new fresh SPListItem, not from properties.ListItem, but with SPListItem item = properties.List.GetItemById(properties.ListItemId).
    – Evariste
    Apr 14, 2015 at 16:06
  • I try SPListItem item = properties.List.GetItemById(properties.ListItemId) and I got the same error. Yes, the file is checked out and it's a publishing page from the page doc lib.
    – user41391
    Apr 14, 2015 at 16:12
  • Then, the simplest/best/fastest/etc. option may be to have that ER on the checked-in event. Is this an option?
    – Evariste
    Apr 14, 2015 at 17:03
  • It's not a good option for what we do. I have no solution :(
    – user41391
    Apr 14, 2015 at 17:19

That's the solution :

using (SPWeb web = properties.OpenWeb())
                     bool oldUnsafeUpdates = web.AllowUnsafeUpdates;
                     web.AllowUnsafeUpdates = true;

                     SPList list = web.Lists.TryGetList("Pages");

                     SPListItem item = list.GetItemById(properties.ListItemId);

                     item["PublishingIsFurlPage"] = true;

                     web.AllowUnsafeUpdates = false;

Edit Work when adding one document. The second one give me the error The file Pages/z.aspx has been modified by SHAREPOINT\system


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.