locked
How to set a calculated value for DataTime field in the schema.xml RRS feed

  • Question

  • I created a custom site definition for a WSS site. I added a custom DateTime field to the Announcements lists in the Schema.xml. I'm trying to pass a default value to it, but I'm not having any success.

    I want the default date in the calculated value field to be "[today]+30". I'm able to set the defaut value to today by using the default element "<default>[today]</default>" but I cant default it to the calculated value.

    The xml code i have used to set the default to today is as follows: -- I need it to be today + 30, but I cant get the syntax correct.
    <Field Type="DateTime" Name="Expires" DisplayName="Expires"
    Format="DateOnly" FromBaseType="TRUE">
    <Default>[today]</Default>
    </Field>

    Monday, February 4, 2013 3:31 AM

Answers

  • Hi 2_Lee,

    Try the following:

    <DefaultFormula>=[Today]+30</DefaultFormula>

    Hope this helps,


    Teodora


    • Edited by Teodora Gancheva Monday, February 4, 2013 8:40 AM
    • Marked as answer by Ayzmilee Tuesday, February 5, 2013 2:01 AM
    Monday, February 4, 2013 8:40 AM

All replies

  • Hi 2_Lee,

    Try the following:

    <DefaultFormula>=[Today]+30</DefaultFormula>

    Hope this helps,


    Teodora


    • Edited by Teodora Gancheva Monday, February 4, 2013 8:40 AM
    • Marked as answer by Ayzmilee Tuesday, February 5, 2013 2:01 AM
    Monday, February 4, 2013 8:40 AM
  • That works, Thanks very much
    Tuesday, February 5, 2013 2:02 AM
  • I tried but that was not working..Its not showing field in my list

    so i use that one..its working fine..

    In this "Created" is a default column...

    <Field ID="{01854464-EABC-4726-A517-397A4EA224C2}" Name="dueDate"  StaticName="dueDate" DisplayName="due Date" Description="dueDate" Group="MyDoc Content Types" Type="Calculated" Format="DateOnly"  ResultType="DateTime" ReadOnly="TRUE"  >
        <Formula>=DATE(YEAR(Created),MONTH(Created),DAY(Created))</Formula>
        <Default></Default>
        <FieldRefs>
          <FieldRef Name="Created" />
        </FieldRefs>
      </Field>

    Regards :

    Munish Kumar

    Friday, November 15, 2013 11:54 AM