none
how to write valdiation for custom site column using element.xml

    คำถาม

  • hi,


    I am trying to write valdiation for my custom site column using element.xml in below format.But its not getting work.Any suggestions/Approaches will be great.


    <Field ID="{769546A4-5AA9-4A93-B41E-E48999897A5C}" Type="DateTime" DisplayName="MyDate" Required="TRUE" EnforceUniqueValues="FALSE" Indexed="FALSE" Format="DateTime"    StaticName="MyDate" Name="MyDate" >
        <Validation Message="Start Date Should not be more than 30 days out from current date.">=(([MyDate])&lt;([Today]+30))</Validation>
        <Default>[today]</Default>
      </Field>

    Thanks & Regards, Krishna

    12 มีนาคม 2555 13:54

คำตอบ

ตอบทั้งหมด

  • Hello Krishna

    I found some blog that could help you

    http://www.3guysonsharepoint.com/?p=364

    <Field ID="{4A402010-E7A5-4A91-A536-B522EB624B38}"
           Type="DateTime"
           Format="DateOnly"
           Name="MyReviewDate"
           StaticName="MyReviewDate"
           DisplayName="Review Date"
           Group="My Columns">
        <DefaultFormula>=DATE(YEAR(Today)+1,MONTH(Today),DAY(Today))</DefaultFormula>
        <Validation Message="Review Date must be between one week and three years in the future!">=AND([Review Date]&gt;=TODAY()+7,[Review Date]&lt;=DATE(YEAR(TODAY())+3,MONTH(TODAY()),DAY(TODAY())))</Validation>
    </Field>

    hope this will help

    Christopher.


    Best regards, Christopher. Blog French Blog English

    12 มีนาคม 2555 14:41
  • hi Christoper thanks for Quick Reply,

    I tried in below syntax/foramt but no luck.Not getting validated.

    <Field ID="{769546A4-5AA9-4A93-B41E-E48999897A5C}" Type="DateTime" DisplayName="MyDate" Required="TRUE" EnforceUniqueValues="FALSE" Indexed="FALSE" Format="DateTime" StaticName="MyDate" Name="MyDate" > <Validation Message="SSSPPSS.">=AND(TODAY()+30>=[MyDate])</Validation>

    <Default>[today]</Default> </Field>


    Thanks & Regards, Krishna


    • แก้ไขโดย Krishna_2011 12 มีนาคม 2555 14:52
    12 มีนาคม 2555 14:51
  • Can you change your code to test the below one

    <Validation Message="SSSPPSS.">=AND(TODAY()+30&gt;=[MyDate])</Validation>


    Best regards, Christopher. Blog French Blog English

    • ทำเครื่องหมายเป็นคำตอบโดย Krishna_2011 14 มีนาคม 2555 7:14
    12 มีนาคม 2555 14:57
  • Christopher above syntax which u mentioned worked like charm for me.

    Can you suggest changes for one more field with mentioned below validation.Below one also throwing syntax error.

     <Field ID="{E05E97A6-7EDE-4245-A12C-6612B59703C2}" Type="DateTime" DisplayName="My Date" Required="FALSE" EnforceUniqueValues="FALSE" Indexed="FALSE" Format="DateTime" Group="My Columns"  StaticName="MyDate" Name="MyDate">
        <Validation Message="Test Meesage.">=AND(TODAY()&gt;=[MyDate])</Validation>


      </Field>


    Thanks & Regards, Krishna

    14 มีนาคม 2555 7:14
  • Christopher above syntax which u mentioned worked like charm for me.

    Can you suggest changes for one more field with mentioned below validation.Below one also throwing syntax error.

     <Field ID="{E05E97A6-7EDE-4245-A12C-6612B59703C2}" Type="DateTime" DisplayName="My Date" Required="FALSE" EnforceUniqueValues="FALSE" Indexed="FALSE" Format="DateTime" Group="My Columns"  StaticName="MyDate" Name="MyDate">
        <Validation Message="Test Meesage.">=AND(TODAY()&gt;=[MyDate])</Validation>


      </Field>


    Thanks & Regards, Krishna

    I'm not a specialist in validation (your new one looks like correct for me...)

    maybe you can try

    <Validation Message="Test Meesage.">=AND(TODAY()+0&gt;=[MyDate])</Validation>


    Best regards, Christopher. Mon Blog My Blog

    14 มีนาคม 2555 9:14
  • Experts,

    I am using a column of type Text in SharePoint list, that stores the value of year like 2010,2011 etc. Now validation should be like entered value must be a number of exactly of length 4 and it should not two years before the current year & five years after the current year. eg: current year is 2012, then the entered value should not be less than 2010 & should not be greater than 2017.

    Please note that the column is of type TEXT not DATE

    <Field ID="{b1c078c0-63ed-4eb5-ade0-10d7701970ce}" Name="DevPipelineYear" Type="Text" Group="DevPipelineCustomSiteColumns" DisplayName="Year" Indexed="TRUE" EnforceUniqueValues="TRUE" MaxLength="255">
    <Validation Message="Year field must be a four digit number">=AND((ISNUMBER([DevPipelineYear]+0)),(LEN(DevPipelineYear)=4)) 
    </Validation>

    I will appreciate your efforts if you put some light on formula for my above requirement.


    Ram Sharma

    4 กันยายน 2555 9:40