0

I've recently added a Date column to a Document Library and would like to update all of the existing documents with a calculated date.

The new Date Column [DueDate] can be entered manually on Creation/Edit, but I would need it to Default to 1 Year later than another column called [Date]. Since this needs to be editable, it cannot be a calculated column.

I've already attempted to do calculations in the Default box on the [DueDate] column, but since you can't reference other columns this won't work.

What's the best way to achieve this?

6
  • You can use JavaScript and attach an on value change event on the "DateField". Capture the event and then add one year and default the "NewDateField". Commented Nov 19, 2014 at 18:09
  • Would this be reflected on the client side only? I would need my DueDate field to be updated in the sharepoint database as well.
    – Lando
    Commented Nov 19, 2014 at 18:13
  • Once user saves the data it goes back to the database. Another option is to create event receiver, and then manually update the date field if its left empty. Commented Nov 19, 2014 at 18:16
  • Okay, I will look into that. I've created Event Receivers before, but was hoping to explore my options before going that route. If I go the JS route, I'll still have to manually fire a change event on each existing item in order to update them, correct?
    – Lando
    Commented Nov 19, 2014 at 18:21
  • For the existing items you can create a powershell script to go an update in one shot Commented Nov 19, 2014 at 18:24

2 Answers 2

1

To accomplish this, follow these steps:

  1. Create your date field "BaseDate" (in my case I created a Date only field)
  2. Create a calculated field "BaseDatePlus1" with the following formula =DATE(YEAR(BaseDate)+1,MONTH(BaseDate),DAY(BaseDate))
  3. Create your other date field "Due Date"(in my case I created a Date only field)
  4. Now create a SharePoint designer workflow that set a field in current item as follows: Set Due Date to CurrentItem:DatePlus1 and configure it to run every time you create an item in the list (or whatever you want)

Later, you can hide the calculated field from your form using SharePoint Designer.

Hope this helps.

0

Two options

  1. Use JavaScript to update the default value in client side. On save the data will go into the list
  2. Use an event receiver. Update the field to the calculated value in case of empty

For existing data you can create a powershell script which can go and default the date values.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.