Quantcast
Viewing all articles
Browse latest Browse all 26374

Document ID not generated after file is added into library from event receiver

I have some code inside an ItemUpdated event receiver which takes the file of the list item being updated, and inserts the file into another site collection's library.  The destination site collection has the Document ID service activated, but after the document is inserted by the event receiver, no document ID is generated.  

I created a console program to test out the same insertion code, and a document ID IS generated in the destination library.  My code is below.. would appreciate if anyone can give me any insights? 

public override void ItemUpdated(SPItemEventProperties properties) { this.EventFiringEnabled = false; SPListItem docItem = properties.ListItem; SPFile docFile = docItem.File; using (SPSite site = new SPSite(destSiteUrl)) { using (SPWeb web = site.RootWeb) { SPList library = web.Lists[SystemConfigSrvc.GetString(SystemConfigSrvc.Keys.TEMPORARY_LIST_NAME.ToString())]; SPFileCollection fileCollection = web.Files; SPFile file = fileCollection.Add(filePathAndName, docFile.OpenBinary(), true); } }

this.EventFiringEnabled = true;

}



Viewing all articles
Browse latest Browse all 26374

Trending Articles