Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Saturday, February 25, 2012 1:42 PM | 7 votes
In SharePoint, we can create the auto-incremental field by many ways, I am going to discuss two ways of doing it.
- Calculated field
- Item Event Receiver
1. Using Calculated field:
Using this we can accomplish it without doing any programing and it is a relatively simple way of doing it. By using “Calculated” column in SharePoint List we can create auto-increment field. We can accomplish this by creating a new column and choosing the column type as “Calculated (calculation based on other columns)”. And in Formula field, we have to enter [ID]
In fact this will be using the values from “ID” field from SharePoint list that starts from 1.
For example, if we want to start our auto-increment column from 100, we can modify the “Formula” field of Create New column screen, we can have to enter [ID] + 99
For detailed info please follow the blog I wrote here: http://faisalrafique.wordpress.com/2011/03/19/creating-auto-increment-field-in-sharepoint-list/
2. Using Item Event Receiver:
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.
All replies (22)
Friday, May 18, 2012 12:28 PM
I have created a doc lib, Created a Calculated column having ("CD-W-"&[ID]+2) formula. but the problem is it didn't generate unique id at run time as you can see in the image.
but when i open the the setting page of column from "Document Lib" settings, and do nothing just click Ok it refresh the IDs .
What would be the problem.
Tuesday, May 29, 2012 4:13 PM | 4 votes
I'm having the same issue. upon adding a new item it creates the ID column as "0". only after I edit the column (list settings\change column) and click "ok" do the values set incrementally. Tried in multiple browsers, tried refreshing list page, tried waiting to see if it was some timing issue...no joy.
Thursday, July 26, 2012 2:47 PM | 1 vote
Adding calculated column formulae [ID] is not giving auto incremental value. It is always displaying 0(zero) only.
I tried with [ID]+1, it is repeatedly giving 1 only.
I am very thankful, if you guide us.
Thanks,
- GEM
Thursday, July 26, 2012 4:35 PM | 1 vote
Hi
Yes beacause , ID is filled after the item is added ( and beacause ID = 0, it's Ok that your result is allways 1)
Create to your list the column ( as numeric )
and add a workflow to your list which will fill the value in this comun with your formula
Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.
Tuesday, July 31, 2012 3:06 AM
Can you please provide reference link(s), if you have any!
What type of workflow I need to develope? How?
Thanks,
- GEM
Wednesday, August 29, 2012 12:44 AM
Use Sharepoint Designer to create a Workflow for the list containing the field to increment. For my project I had an Invoice field that I wanted to start with 1001 and increment from there so I made the following workflow to do this.
In the new workflow screen in Sharepoint Designer create two actions in Step 1:
-
- Calculate Current Item:ID plus 1000 (Output to Variable: calc)
- then Set AutoIncrementNumber to Variable: calc
This is just a guide. If you just want the auto-increment to start with 1 then you can just use this step
- Set AutoIncrementNumber to Current Item:ID
Also, make sure you select the correct name for your field in the Workflow action instead of AutoIncrementNumber.
Save the Workflow, close it, and then open it again in Sharepoint Designer. Check the box for "Start workflow automatically when an item is created." Save it again and then click on the Publish button to make it active on the sharepoint site. The value should now increment for each new item created in the list.
Wednesday, August 29, 2012 6:07 AM
Hi Ken,
May I request a detailed guide?
lets say i just want to autoincrement the "PO Number" column.
Thanks
Sunday, September 2, 2012 5:32 AM
Hi,
There is another option, every item in a list or document library has an ID associated with it so you can use that.
Just go to the list settings, modify view in which you would like to display it and check the display box on ID field.
Thursday, October 4, 2012 12:57 PM
Khurram,
You are brilliant.
Thanks, Chintan
Thursday, October 4, 2012 1:02 PM
Hi Ken,
I tried your approach. ID is a string. So your workflow will append ID to a value. e.g.
Calculate Current Item:ID plus 1000 (Output to Variable: calc) will give 1 plus 1000 = 11000
Thanks, Chintan
Wednesday, November 21, 2012 3:12 PM | 1 vote
Hello Abdullah Memon
Try this formula ="CD-W-"&ID+2.
It works for me
Regards,
faisal
faisal rafique
Wednesday, November 21, 2012 3:20 PM | 1 vote
HI GEMZz
try this =ID+2
Regards
faisal rafique
Wednesday, November 21, 2012 3:22 PM
In my opinion, this can be simply as I have shown above so no need for a workflow here
Regards
faisal rafique
Thursday, December 6, 2012 6:08 PM | 2 votes
Try this formula ="CD-W-"&ID+2.
It works for me
Regards,
faisal
faisal rafique
Friday, January 3, 2014 7:18 AM
Hi,
Please follow below steps to create a auto increment number coloumn.
1)Go to list setting.Click on Create column.
2)Select the column type calculated column.In the formula write =[ID] and select data type returned by the coloumn to Number.
Now check the auto increment number column is there.
Friday, January 3, 2014 7:35 AM
Hi
this behavior is absolutely normal.
The ID field is filled only after submit buttn is clieckd, and the item is created, after all other fields are filled ( alos calulcated column )
So the only way is to use a workflow to do it
Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.
Sunday, July 6, 2014 2:14 PM
Hi,
Kindly check belwo link
http://stackoverflow.com/questions/72537/auto-number-column-in-sharepoint-list
http://www.sharepointbasic.com/2011/04/generate-auto-number-field-in.html
Hasan Jamal Siddiqui(MCTS,MCPD,ITIL@V3),Sharepoint and EPM Consultant,TCS
Sunday, July 6, 2014 3:21 PM
Hi
Your first solution doesn't work. You can't use ID value before the item is creted. The order when an item is creted :
I) all standard fields are fiiled
ii) all calculated column are resolved
the item's form is closed with save or add button
iii) the ID value is filled by Sharepoint
Next it's starting ( if exist ) the workflow associated to that list
So the solution it's to use a workflow which will start when an item is creted, and inside there, fiill a specific new column with apporpiate value based on a formula which contain item's ID value
Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.
Thursday, March 5, 2015 6:45 AM
Goog code
Monday, July 27, 2015 2:02 PM
You can also use a simple SharePoint Designer based workflow to update column.
Regards,
Rupesh Singh
Please don't forget to mark it as answered, if your problem resolved or helpful.
Tuesday, February 16, 2016 4:16 AM
What if user deletes an list item ?. The next ID value will not represent an incremented number of total items present. Event receiver is a better approach. On ItemAdding, get the total number of items + 1 and save it in your new number. This can be done by JSOM too specially if you don't want to persist this incremented columns and need it only for display purpose.
Thursday, February 25, 2016 4:17 AM
SharePoint: How to Create an Auto-Incrementing Number Field For Use in a Custom ID