in

SharePoint University

Clean slate. Nothing but SharePoint.
Go, SharePoint!

Custom fieldtype datetime sitecolumn and set the default date

Last post 04-07-2008 3:50 AM by spa77. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 09-19-2007 3:30 AM

    Custom fieldtype datetime sitecolumn and set the default date

    Hi All,

     

     This is my first post and i hope you can help me.

    I have created a feature with sitecolumns and contenttypes. One of the columns are startdate and expiredate.

    <Field ID="{03AA9C21-81F7-41d7-B5A5-CBEB40768C46}"
         Name="StartDateColumn"
         DisplayName="Start date"
         Group="News Service General"
         Type="DateTime"
         ShowInEditForm="TRUE"
         ShowInDisplayForm="TRUE"
         ShowInNewForm="TRUE"
         Description="Date from which news should be published."
         Format="DateOnly" />

    But i want make the startdate default date of today. And the expiredate = default(date.Now) + 1 week.

     

     Can anybody help me please with this problem.

     

    Thanks a lot.

     

    Juniormoss :)

    Filed under: , ,
  • 09-19-2007 9:23 AM In reply to

    Re: Custom fieldtype datetime sitecolumn and set the default date

    If you look at the schema for field definitions, there are some sub items that can be added. IE:

    <Field ID="{03AA9C21-81F7-41d7-B5A5-CBEB40768C46}"
         Name="StartDateColumn"
         DisplayName="Start date"
         Group="News Service General"
         Type="DateTime"
         ShowInEditForm="TRUE"
         ShowInDisplayForm="TRUE"
         ShowInNewForm="TRUE"
         Description="Date from which news should be published."
         Format="DateOnly" >
         <Default>[Today]</Default>
    </Field>

    This might work, but I'm currently unable to test it.

  • 09-19-2007 9:29 AM In reply to

    Re: Custom fieldtype datetime sitecolumn and set the default date

    thank you..

     i know the option to add a default item to a custom field type, but how to give value of date of now.

    So you said that that is [Today].

    i hope thiw will work.

    Thank you.

  • 09-19-2007 10:16 AM In reply to

    Re: Custom fieldtype datetime sitecolumn and set the default date

    Hi,

     

     

    <default>[Today]</default> doesnt work for the sitecolumn.

     

    Do you know something else? And for the expiredate i need StartDate(today) + 1 week. this is much more complex i think.

     

    Can anybody help me?

     

    Regards

    juniormoss

  • 09-19-2007 1:09 PM In reply to

    • fdb1
    • Top 50 Contributor
    • Joined on 06-20-2007
    • Mars

    Re: Custom fieldtype datetime sitecolumn and set the default date

    Why are you doing this via code?  You can create custom lists via the UI settings/tools.  If you can modify the list settings for the columns, then you can set the default.  For a Date type field, there is an option to default it to 'Today'.  For the StartDate, if you create a Date type field then you should be able to set the Default ot [Today]+7 which would be today plus 1 week. 

    Filed under: ,
  • 09-19-2007 1:30 PM In reply to

    Re: Custom fieldtype datetime sitecolumn and set the default date

    hi fdb1,

    uhhmm.. i have 1 feature to install automatically the sitecolumns with the contenttypes. In the future this will be used in more environments..

    In your case i have to do this manually but i dont want that.. I want to do this automatically.

    I know the option you gave, but that is not the way i want.

    thanks any way

     

    juniormoss

  • 04-07-2008 3:02 AM In reply to

    • spa77
    • Not Ranked
    • Joined on 04-07-2008

    Re: Custom fieldtype datetime sitecolumn and set the default date

    Have you tried adding the defaultformula tag instead of just default?

    <DefaultFormula>=Today+7</DefaultFormula>

     

  • 04-07-2008 3:34 AM In reply to

    Re: Custom fieldtype datetime sitecolumn and set the default date

    hi spa77,

     

    thanks for your reply.. but can i use this tag in sharepoint? will it be recognized?

  • 04-07-2008 3:50 AM In reply to

    • spa77
    • Not Ranked
    • Joined on 04-07-2008

    Re: Custom fieldtype datetime sitecolumn and set the default date

     

    I've used this setting successfully within a schema.xml file on a list before and it worked fine.  What I was basically doing was setting a default expiry date field in a list item so that it wasn't always set to 'today', rather in 30 days time.  Here is the full Field node within the xml file I used.

    <Field ID="{E2D38AF5-6DD4-4b3d-96F4-9C5DACC78EB3}" Type="DateTime" Name="EndDate" DisplayName="$Resources:core,End_Time;" Format="DateTime" Sealed="TRUE" Required="TRUE" Filterable="FALSE" FilterableNoRecurrence="FALSE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="EndDate">
    <!--
    _locID@DisplayName="camlidE2" _locComment=" "
    <Default>[Today]</Default> -->
    <
    DefaultFormula>=Today+30</DefaultFormula>
    </
    Field>

    I hope this helps you.

Page 1 of 1 (9 items)

Need SharePoint Training? Attend a SharePoint Bootcamp!
Forum content (c) original posters. Everything else (c) 2008 SharePoint Experts, Inc.