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!
Event Receiver is a feature in SharePoint to handle events that are triggered when an action happened on SharePoint objects. One example is when you need to notify a person when a file is uploaded to a document library.
There are two types of Event Receiver in SharePoint, Synchronous Event Receiver. Asynchronous Event Receiver.
Select event receiver and enter the title of the event receiver. Click the Add button. Select List Item Events in the type of event receiver and select the custom list option from the event source. Then select "an item was added" in events and click Finish.
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!";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With