We need to do some calculation in an ItemAdding event receiver that uses a monotonically number. Because we need to use the ItemAdding event (rather than the ItemAdded event) we cannot use the item ID for our purposes (ID hasn't been generated yet).

Is there a robust (multiple frontends) way to implement a counter using the SharePoint infrastructure?

1 Answer 1


Indirect answer to your question, you can get item ID in itemadding event too, try this,


For more information check this link out.

  • Your reference (and idea) is for the ItemAdded event (after the item has been created and an ID has been generated). This question is about the ItemAdding (the item has not yet been added to the DB) event. Commented Mar 25, 2013 at 21:12
  • @PhilippSchmid my idea is for itemadding not itemadded as I clearly stated, did you tried it yet ?, I do know the difference between itemadding and itemadded and think you need to do a bit study on it, did you went through link in my answer ? Commented Mar 25, 2013 at 21:18
  • Yes, both answers in the link you provided talk about the ItemAdded event. I also did the experiment and the AfterProperties["ID"] is null. Since the item hasn't been created in the content database when ItemAdding is called, it doesn't know yet what the next index will be (since another item could be added while the ItemAdding event receivers are being executed). Commented Mar 25, 2013 at 21:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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