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

I have a calculated field in a SharePoint 2007 list. I want this calculated field to include the ID of the item but I could not find the ID column inside the "Insert Column" List box.

How should I go about in order to get my calculated field to have the ID of this item. (For your info: the calculated field does not only just contain the ID of this item.)

share|improve this question
add comment

3 Answers

up vote 0 down vote accepted

If you need to use the ID in a calculation, the best approach is to do the calculation in a workflow and set a column to the value returned by the calculation.

IDs can work in calculated columns, they are unreliable, speaking from experience. Now I always use On creation and on change workflows in situations where I absolutely have to use the ID value in some sort of calculated column.

share|improve this answer
add comment

Thanks everyone for your help but I have do some testing and notice that I can simply use =[ID] to retrieve the ID even though the ID is not listed inside the "Insert Column" list box.

Kind of quite surprise for me as I thought that the ID field will be display in the "Insert Column" rather than hidden.

(Do let me know if it does not work in your case.)

share|improve this answer
    
=[ID] works when you set it up, but as soon as you create new items it'll break. –  Christophe Nov 10 '11 at 5:33
    
Yeah. That's bad. When I create a new items, every things break. (Wonder if this is a bug or not). Thanks Christophe for the enlightenment. –  Anderson Karu Nov 10 '11 at 8:59
    
It isn't intended to be used in calculated columns. you can add it, but as I mentioned, the functionality of it is buggy. Using a workflow to set a column value to the ID to use in your calculated filed or building the calculated field directly in a workflow are your best, no code options. –  PirateEric Nov 10 '11 at 18:26
add comment

Unfortunately I don't think you can include ID as part of a calculated column. It's been a while since I looked at this but from memory I think it has to do with the ID column having a null value until the item is saved for the first time, so SharePoint doesn't allow it.

A workaround that I've used in the past is to implement an event handler on the list which will update a custom integer column on the list with the item id after the ItemAdded event has occurred. Your calculated column can then use this custom column as part of its calculation.

share|improve this answer
add comment

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.