I need to rename document after creating from MS Office Word.
I've created EventReceiver OnItemAdded where I am trying to change "FileLeafRef" field:
public override void ItemAdded(SPItemEventProperties properties)
{
this.EventFiringEnabled = false;
properties.ListItem[SPBuiltInFieldId.FileLeafRef] = "SampleName.docx";
properties.ListItem.Update();
this.EventFiringEnabled = true;
base.ItemAdded(properties);
}
Result: The file is locked for exclusive use by .
When I am trying SystemUpdate() File is checked out after saving, but I do not need to check out file.
Where I am wrong?