Page 1 of 1

"Simplified notation" value calculation: how?

Posted: Mon Jan 21, 2019 6:52 pm
by claude vidal
Let's say a form with two date fields, Date1 and Date2. I'm trying to set Date2 to "Date1 + 2" by specifying a value calculation of "Simplified notation": Date1 + 2. Does not seem to work. What am I missing?

Update: here is what I get for Date2 and I only get this after I select any date from the Date2 calendar
image.png
image.png (7.61 KiB) Viewed 1040 times

Re: "Simplified notation" value calculation: how?

Posted: Mon Jan 21, 2019 9:14 pm
by TrackerSupp-Daniel
Hello Claude,

This will not be possible with simplified notation, as a custom script is required.
I have included one here:

Code: Select all

//Date format is important, make sure that ["dd mmmm yyyy"] matches your desired format
//"Date1" is the field name for the field you are selecting manually
var date= util.scand("dd mmmm yyyy", this.getField("Date1").value);
//+2 in this line is the number of days to add to the original field
//IE 2 months would be +60
date.setDate(date.getDate()+2)
if (this.getField("Date1").value!="")
{
//Same here, ensure that date format matches
event.value=util.printd("dd mmmm yyyy",date)
}
//this keeps the field blank until an input exists in the first field
else
{event.value=""}
Simply create a text field (you can lock it if you want to prevent users from editing it manually) then change the value calculation to "custom action" and choose "Run a javascript" then paste the code above into the window.

This script assumes that the first date field is named "Date1" so you may need to modify the script for it to work with your existing document.

Re: "Simplified notation" value calculation: how?

Posted: Mon Jan 21, 2019 9:37 pm
by claude vidal
Daniel,

Thanks, did the job.

Re: "Simplified notation" value calculation: how?

Posted: Mon Jan 21, 2019 10:27 pm
by TrackerSupp-Daniel
:D