SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

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


For more information check this link out.

share|improve this answer
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. – Philipp Schmid Mar 25 '13 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 ? – Muhammad Raja Mar 25 '13 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). – Philipp Schmid Mar 25 '13 at 21:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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