3

What is in SharePoint 2013 on premise the best way to create an autonumber system? It's for an expense note system and it should be nice to have something like 2014/0001.

I know there are different ways to achieve this but I don't have any experience with the best way to do it. Should I do it using a workflow, or is maybe an event receiver a better way?

  • where is this data going to be stored in? i presume a list? if so that should be easy to create! – Ali Jafer Aug 20 '14 at 7:02
3

It is really depend upon you requirement. from simplest way to workflow to event receiver.

  • Simple way is using the calculted column
  • use the workflow( personally i dont like this)
  • event Reciever: By using this strategy, users have advantage to edit the existing values, we can also avoid it by making field read-only on feature activation. Using item event receiver, on ItemAdded event, we have to find the highest value among previously added items and then save the incremented value to current newly created auto-incremental column. In code given below, its looks up for the highest value in the existing items, and adding the incremented value to the newly added item.

Check the below links: http://lor-sinclair.blogspot.com/2013/10/creating-auto-increment-field-in.html http://dlairman.wordpress.com/2011/01/10/add-a-unique-auto-incrementing-column-to-a-sharepoint-list/

4
  1. Using an event receiver: You can check the last added item, then increment it with 1. Then modify the number as 2014/001, 2014/002 and ect... No need to have workflows.

  2. Another way is having a property bag value which stores the last added id, then increment it by 1 and save, set that value to the number to the list item. This too can be done using an event reciever.

When you add an event receiver, it make sure it creates ID regardless you use a form or not.

If you are concerned about auditing, then better maintain a history list or a log as well.

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.