Property Promotion Issue in ItemAdding Event

There is an issue in ItemAdding event which is specific to Office 2007 documents. When we set value for a column using ItemAdding event, the value disappears after the item is added to the library. This is happening ONLY for Office 2007 documents.
For example, we have a custom column ‘Owner’ in the document library. We are setting the value of ‘Owner’ column in the ItemAdding Event as below.

When a document which is not Office 2007 document is uploaded, it is set correctly and the value is saved to the item.


However, when a document of type Office 2007 is uploaded, the field value is set in ItemAdding, but the value becomes blank after the item is added. (Note that the ‘Title’ column is blank in while uploading the document. This is a different issue.)


This is an issue with Office 2007 and the WSS 3.0 xml parser. When the properties are promoted from the Office 2007 document, the parser attempts to assign document properties to the list properties in SharePoint (property promotion). However the problem is that this event occurs after any ItemAdded, or ItemUpdated events, so the property gets overwritten with the value in the document, which is of course, blank.

We had a Microsoft case on this issue and following are the workarounds suggested.

(1) Set the owner field as not required, so that you later can change the field to the current user value (in ItemUpdated event)

(2) You can set the owner field to read/Only, but this would hide the field in the UI and the user cannot modify the value, so that the owner field is always the current user, if the ItemAdding handler set this value appropriate.

(3) You can go to SharePoint 2010, which does not have this issue.

(4) Set SPWeb.PareserEnabled = False for the web, but this has also draw backs. F.e. you wouldn’t see the properties in the Office documents, if PareserEnabled is set to false; see

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.parserenabled.aspx

(5) Within the ItemAdding event you could create a new thread which sleeps for some seconds and after that it will do the work, setting the owner property appropriate to the list item. That could work but because of the delay, the change will be done later.


1 comment:

Unknown said...

It's been good to see your blog when I always look for such type of blogs. It’s great to discover the post here. You have done really a superb job with your web site. Marvelous stuff is here to read. UK Property Advice Events