Reputation: 14112
I'm trying to update one of the properties of a word document from an event receiver.
I'm handling it with the ItemAdded event and updating the property as is:
// Modify property
DisableEventFiring();
properties.ListItem.File.CheckOut();
properties.AfterProperties[HelloWorldInternalFieldName] = "Hello World!";
properties.ListItem.UpdateOverwriteVersion();
properties.ListItem.File.CheckIn("Updating Property!");
properties.ListItem.SystemUpdate();
EnableEventFiring();
I'm getting an exception when I'm trying to modify it and it is saying:
The event does not support change of properties.
Does anyone have an idea why and why I cannot update the property after I save the document to the document library in Word?
Thanks!
Upvotes: 7
Views: 4716
Reputation: 14112
I know what the problem is:
AfterProperties is read-only in -"ed" events. You can just modify the list item:
properties.ListItem["HelloWorldInternalFieldName"] = "Hello World!";
Upvotes: 14