In one of our projects, we are trying to register an Event Sink for a
Document Library. In the event sink we need to update few Taxonomy
Fields of the uploaded file. We are able to succeed in this regard. But
when we fire a search with the Metadata we fail to view the file in the
restltset.
However by removing the update taxonomy fields functionality (shown bold
in the code snippet - this uploads Metadata to the File) in the Event
sink or removing the Event Sink from the document library we are able to
successfully search for the document.
How to overcome this problem? The code snippet of the EventSink is given
below:
Code Snippet:
-----------------
public void OnEvent(Microsoft.SharePoint.SPListEvent evt)
{
if(evt.Type == SPListEventType.Insert)
{
SPWeb mySite = evt.Site.OpenWeb();
file = mySite.GetFile(evt.UrlAfter);
try
{
file.Item["Last Modified By"] = evt.UserLoginName;
file.Item.Update();
}
catch(Exception e)
{
LogInfo("My Update " + e.Message);
}
}
}
Do you know someone who can help? Share a link to this thread on twitter, or facebook.