Posts Tagged ‘Computed’

Do not use SharePoint Computed fields

Friday, January 16th, 2009

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.