Search code examples
javascriptsharepointcustom-lists

How to add days into [Today] SP 2010?


How to add day in a customlist column with value 3 into another customlist column with [Today] in SharePoint 2010?

Example Customlist DayExp ExpireDay 3 ... /I don't want to set the default calculate field into =[Today]+3 because it is fixed. I store in a Customlist column because I can edit the ExpireDay in the future to 1 or 2 or more days as I like./

Customlist KnowledgeSubmission SubmissionValidTo ... /I want to add ExpireDay column value(3) with [Today] into this column/

So how to add [Today] with ExpireDay value?

Javascript code function or just simple Onsave action in the form may be helpful as well.

Thank in advance for your help!


Solution

  • Because a list only calculates the values of a list when it is saved, you can never use the value of "Today" in a calculation (as it changes every second or so).

    The default calculation of [Today] only happens when you are in the new form. You could add some jQuery to the Editform.aspx and it is not too hard, but it may be easier to create a calculated field as:

    =Modified+ExpireDay
    

    Which will be whatever that date the item was saved + 2 days.