Calculated Date Field (14+ days from date entered in another field)

New Here ,
Mar 05, 2021 Mar 05, 2021

Copy link to clipboard

Copied

Fisrt off, I have spent several hours searching and trying different answers but nothing seems to work for this seemingly simple request.

 

I have two form fields, one is a date field (mm/dd/yyyy) the user will select the date for, and the other is a calculated date field that needs to add 14 days (same format) to the date the user selects. 

 

There have been some very complicated formulas I have tried and some very simple ones (Datefield1+14). I would think this could be done as a "Simplified Field Notation", however I cannot seem to find the formula to accomplish this...

TOPICS
JavaScript, PDF forms

Views

81

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct Answers

Adobe Community Professional , Mar 05, 2021 Mar 05, 2021
As "Custom calculation script" of field where you select date use this.var date = util.scand("mm/dd/yyyy", event.value);if(event.value == "")this.getField("Text1").value = "";else {date.setDate(date.getDate() +14);this.getField("Text1").value = util.printd("mm/dd/yyyy", date);}Change "Text1" to the name of the field where you want to add +14.

Likes

translate

Translate

Translate
Adobe Community Professional , Mar 05, 2021 Mar 05, 2021
Hi,   Just 2 cents on the above answer, I would use a "custom validation script", my reason for this is that a custom validation script is only called when the field changes, whereas a custom calculation script is called when any field changes and in this instance we only need the script to run when the actual value of field changes.   Malcolm

Likes

translate

Translate

Translate
Adobe Community Professional ,
Mar 05, 2021 Mar 05, 2021

Copy link to clipboard

Copied

As "Custom calculation script" of field where you select date use this.

var date = util.scand("mm/dd/yyyy", event.value);
if(event.value == "")
this.getField("Text1").value = "";
else {
date.setDate(date.getDate() +14);
this.getField("Text1").value = util.printd("mm/dd/yyyy", date);}

Change "Text1" to the name of the field where you want to add +14.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Mar 05, 2021 Mar 05, 2021

Copy link to clipboard

Copied

Hi,

 

Just 2 cents on the above answer, I would use a "custom validation script", my reason for this is that a custom validation script is only called when the field changes, whereas a custom calculation script is called when any field changes and in this instance we only need the script to run when the actual value of field changes.

 

Malcolm

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 05, 2021 Mar 05, 2021

Copy link to clipboard

Copied

I tried it as both custom validation and custom calculation and it does nothing... 

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 05, 2021 Mar 05, 2021

Copy link to clipboard

Copied

Annnnd I know why... I was putting it in the field that I want to be automatically updated and pointing it to the field the user enters, not the other way around. This works! Thank you!

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines