I was using a workflow to change file names to some text and the SP ID, but this has caused issues because the workflows can often take several minutes to complete. I would like to do this during ItemAdding, but I'm 99.999% sure this isn't possible since the ID probably isn't assigned until the document is uploaded. I think I might use ItemAdded, but I don't know how long that might take to kick off. Are either of these reasonable ideas?


This sort of task is more suited to an event receiver. The itemAdded approach will certainly give you access to the ID. An event receiver does not have the typical delay you see with Workflows, it fires right away.

One issue you can experience with ItemAdded events is that they run asynchronously. What this means is that the control is returned to the UI while the Event Receiver is kicked off. This can cause situation where the event receiver is not quite done processing before the display returns to the user, and they won't see the updated values until they refresh the page.

The solution to this is to set the mode for the ItemAdded event receiver to Synchronous in the Elements.xml file for the event receiver using :


In context:


With the Synchronous mode, the display won't return to the user until the processing is complete.

  • 2
    The ID is not present in the ItemAdding AfterProperties (the file hasn't been added to the library yet) – MdMazzotti Mar 11 '14 at 19:20
  • Thanks for clarifying that. I will update my response (and not have to run a test. :) – lwbecker2 Mar 11 '14 at 19:25
  • Appreciate your help! I can't + rep yet, but I will mark as answer. – Dinerdo Mar 11 '14 at 20:23

You can do that in ItemAdded and make it synchronous so it will fire and execute in the same thread after ItemAdding is finished.

You can make an after event syncronous when you define it in your solution, or you can do it with code or PowerShell script.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.