How to copy newly added document with metadata to another document library

copysharepoint

  1. I need to copy the item that user just added (for example. myresume.doc or financial.xls) with the metadata (doc lib obtains the columns from content type, ct obtains the columns from site colum) and copy the item with metadata in a folder called "NativeFile". Every doc library has this folder.

  2. I know itemadded can be used but then I heard itemadded fires before user have a chance to complete the metadata for the item they just added.

What are my options? (new to sp, so some sample code would greatly help. or some good link similar to this issue)

Sharepoint 2007, itemadded or itemadding or itemupdating or itemupdated….

Best Answer

ccomet is correct. With item event receivers alone there's no good way to duplicate the metadata. If you can get away with just copying the file here's whatcha do:

public class MyItemEventReceiver : SPItemEventReceiver
{
    public override void ItemAdded(SPItemEventProperties properties)
    {
        base.ItemAdded(properties);

        SPListItem item = properties.ListItem;
        item.File.CopyTo(item.ParentList.RootFolder.Name + "/NativeFile/" + item.File.Name, true);
    }
}