Do not use SharePoint Computed fields

In this posting I will explain why not to use Computed fields. I was experiencing the following issue with the Computed field type:

I made a Computed column that combines two fields seperated with a minus sign:
 
<Field Name=”IDTitleField” Type=”Computed”>
   <FieldRefs>
      <FieldRef ID=”{GUID}” Name=”Title”/>
      <FieldRef ID=”{GUID}” Name=”ID”/>
   <FieldRefs>
   <DisplayPattern>
      <Column Name=”ID”/>
      <HTML><![CDATA[ - ]]></HTML>
      <Column Name=”Title”/>
   </DisplayPattern>
</Field>

After creating the column you can see the column at the site collection columns. You can add the column to you’re site collections contenttypes. But when you add the contenttype to a list the Computed columns are not copied(!) to the list. Why the Computed fields are not copied I don’t know.

So I start using the Calculated field with the following:

<Field Name=”IDTitleField2″ Type=”Calculated” ResultType=”Text”>
   <FieldRefs>
      <FieldRef ID=”{GUID}” Name=”Title”/>
      <FieldRef ID=”{GUID}” Name=”ID”/>
   <FieldRefs>
   <Formula>=CONCATENATE(ID, ” - “, Title)</Formula>
</Field>

This Calculated field solved my issue. Because the calculated fields are copied when adding the contenttype (which contains the Calculated field) to the list! So my conclusion is to avoid using the Computed field type. Therefore you can use the Calculated field type in many cases.

Tags: , , , , , ,

7 Responses to “Do not use SharePoint Computed fields”

  1. Links 2009-03-12 - Gunnar Peipman's ASP.NET blog Says:

    [...] Do not use SharePoint Computed fields [...]

  2. Lee Richardson Says:

    Thank you Harmjan! I felt like I was doing something wrong and have been killing myself to get this feature to work. The computed column isn’t working so well for me at the moment either (since Title apparently doesn’t refer to a column that exists), but at least I know to stop using the Computed field version that isn’t working at all.

  3. Olivier Heu Says:

    Nice Harmjan, but calculated fields don’t work with lookup.

    How would you concatenate a “Title” string from a lookup fields with another one ? The only way I know is to use type=”Computed” fields when manipulating lookup data. I would be glad to learn another one if someone has an idea…

  4. Harmjan Greving Says:

    Olivier, in your situation you need the Computed field. So you have found a good reason to use computed fields :)

  5. Jenny H Says:

    Thank you!

    I was about to go crazy over this problem….
    I still have to figure out how to concat three fields and format it as an URL, but now the first problem is solved after days of strugle (it seems like yor headline is pointing me in a certain direction in the future).

    Keep up the good work!

  6. David Says:

    I found also a problem with computed
    fields read my blog entry to this:

    http://www.schonebeck.net/?p=43

  7. moab Says:

    I have been having this issue too. The computed field gets copied but without the display pattern. I go it to work by removing the field from the content type, changing to GUID to start fresh, and just defining the field in the list schema.xml only. This works.

Leave a Reply