How to add a calculated field in a list definition (schema.xml)?

Hello,

I'm currently trying to add a calculated field to a list definition (schema.xml).

I have put the following code at the end of the schema.xml for the list I want to create. But when I deploy and activate the feature for the list, it doesn't appear in the list field.

 <Field  ID="{EE20EC4B-4216-4259-A84F-C478CE42B70F}"  Name="EC_EventsMgmt_CalculatedTime"  StaticName="EC_EventsMgmt_CalculatedTime"  Group="EC_EventsMgmt"  Type="Calculated"  DisplayName="Calculated Time"  Required="TRUE"  Hidden="FALSE"  ReadOnly="FALSE"  Format="DateTime">    <Formula>=DATE(2009,1,1)+TIME(EC_EventsMgmt_ScheduleHour,EC_EventsMgmt_ScheduleMinute,0)</Formula>    <FieldRefs>     <FieldRef Name="EC_EventsMgmt_ScheduleHour"/>     <FieldRef Name="EC_EventsMgmt_ScheduleMinute"/>    </FieldRefs>   </Field>

Could you please give me some help and explain me why it is not working?

 

Thanks a lot.

 

  • Moved by Mike Walsh FIN Thursday, April 15, 2010 8:52 AM customization q (of standard file) (From:SharePoint - Development and Programming (pre-SharePoint 2010))
April 15th, 2010 11:38am

Hi there.

If I understand correctly, you create this list within the same feature?

If so, the list isn't available during the propagation, and therefore the calculated field can't be added.

If this is the case, then you could work around this by adding a feature activated event handler to your feature and add the calculated field programmatically in that event.

Hope this helps.

Regards,

Magnus

Free Windows Admin Tool Kit Click here and download it now
April 15th, 2010 12:17pm

 Hi,

  Here also we can check to create calculated columns and Date Time calculated formulas in List Definition.

  http://www.dotnetsharepoint.com/2014/01/how-to-create-calculated-field-in-list.html#.UutIy3e72ik

January 31st, 2014 2:04am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics