7

I created a calculated column with the following formula:

="<a  href='../X_C03 Staff Members/DispForm.aspx?ID="&ID&"'>View</a>"

and included this into a view. The column works OK (i.e. opens the Display form) as long as you do not save changes after editing. Once this happens, the field value of the ID of the correponding listitem is missing. Instead of

../X_C03 Staff Members/DispForm.aspx?ID=24

the link looks like:

../X_C03 Staff Members/DispForm.aspx?ID=

However, as soon as I go to List Settings, open the properties of this column, and click save without changing anything, WOOOPS, the ID-field value is again included.

Can someone please explain this behavior?

  • 1
    Did you find a solution? I am facing the same problem. Thank you. Dave – user10390 Aug 29 '12 at 3:08
  • @dave: Please see my answer below. – Stu Pegg Sep 24 '12 at 12:10
  • I'm having the same problem, does anybody found some kind of work around to make it happens? – user21952 Jan 14 '14 at 15:09
  • @leandro In case your goal is a column with ECB functionality and if you have access to the server machine, you can do it via a powershell script. I based my corresponding changes on this one. Good luck! – StefG Jan 29 '14 at 10:53
4

Unfortunately [ID] isn't actually a supported field in calculated columns.

When a new item's values are being processed it doesn't yet have an ID, so the calculated field has nothing to work with. Since it's the same code that recalculates the item's values on edit, it doesn't bother looking for the ID then either.

However, when the calculated field is edited all the items have IDs, so they're used to recalculated the values. I can only assume there's slightly different processing being used.

This is very similar to the use of Version mentioned here: Using SharePoint version number in calculated column?

3

If anyone else is looking for a solution:

Since [ID] will not work in a calculated field, you need to create a separate number column, e.g. called [IDCopy]. Then you need to create a workflow that will fill in this column with the actual ID value.

After that, you can use the value from the static column in your calculated column:

="<a  href='../X_C03 Staff Members/DispForm.aspx?ID="&IDCopy&"'>View</a>"
0

Use this type of formula in calculated column

="<a href='https://<Domain>.sharepoint.com/Lists/date%20diff/EditForm.aspx?ID="&[ID]&"'>View</a>"

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.