I am trying to update custom metadata for a document when document is added to the library using item updated event, but it is not working. A custom aspx application is using a href element to point to the URL of the document. Click it on it opens windows explorer view similar to the one that is OOB sharepoint 2013 explorer view. Now when user copy the document from library1(says lives in site1 in sitecollection1) to library2(lives in site2 in sitecollection2) via copy-paste option, I need to clear some of the metadata of the document. I am trying the Lukasz's suggestion for it, but the metadata is not clearing. In the debug mode, even though event firing is disabled before update, I see the updated event is being called again one more time which is strange. At the end, my metadata is not being cleared. I tried with both updating and updated event. Any idea? here is my code for updated:
public override void ItemUpdated(SPItemEventProperties properties)
{
base.ItemUpdated(properties);
ClearNotes(properties);
}
private void ClearNotes(SPItemEventProperties properties)
{
try
{
SPListItem listItem = properties.ListItem;
listItem["Notes1"] = string.Empty;
listItem["ReviewNote"] = null;
base.EventFiringEnabled = false;
listItem.Update();
}
catch (Exception ex)
{
//logging error to db
}
finally
{
base.EventFiringEnabled = true;
}
}