Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Whenever we add some new record to a Sharepoint list the ID column gets unique number by itself. I want to get that number after adding record. For example, when we add new record in sql server table and if there is some identity column we get its auto generated id column value by @@IDENTITY. I need a similar thing for a Sharepoint list and ID column.

Please provide some reference or code sample. I hope there is some built in feature for doing it as I don't want to query my data after adding to get its id column value. Looking for some efficient way.

share|improve this question
    
You could store it in a separate one column, one item list that is used for just that purpose, using a SPD workflow that fires on new records being added in the list that you are worried about keeping track of. Just replace what the stored ID is in your 2nd little list with the new one generated when a new list item is created in your target list. Then you can do a lookup on that list item to get the ID for whatever you want it for –  Jack Aug 14 '12 at 7:33
    
i figured it out. after calling .update() on that perticular item. its ID property updates itself and have updated ID value. –  Muhammad Adnan Aug 14 '12 at 7:52

2 Answers 2

i figured it out. after calling .update() on that perticular item. its ID property updates itself and have updated ID value

share|improve this answer

you can call item.SystemUpdate()...also this method has 2 parameters setting sone of them to false...will not create new verions and also with not update the id

share|improve this answer

Your Answer

 
discard

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.