Im trying to do a seamingly simple task in SP 2013.
when the user either Creates a new doc (Ribbon>Files>New Document) or Uploads a File i want them renamed to for example [original_filename]_[datetime].[ext]
I have added a feature receiver (ItemAdded-synchronous) and the core of this is(from this QA) :
file.MoveTo(pathBeforeFileName + "/"+newFileName); file.Update();
When I create new document it works as expected, but when I upload a doc, I get a file not found error right before the properties dialog pops up (or instead of it). The file is renamed correctly when I Close the error dialog.
Am I missing a ways to inform SP that I have renamed the file, its obviously looking for to old filename?
If this is impossible to do, is there any way to distinguish "New Doc" from "Upload Doc"?
More details: I have updated item2[SPBuiltInFieldId.FileLeafRef], but no difference. I have changed back to asynchronous event receiver then I will get past the first error message and get to the properties-dialog, but then I get Another error message at the bottom of that saying "The file [new filename] has been modified by [me] on [datetime]"