Question

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?

Was it helpful?

Solution

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/

OTHER TIPS

  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.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top