"Simplified notation" value calculation: how?

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Sean - Tracker, Paul - Tracker Supp, Chris - Tracker Supp, Tracker Supp-Stefan, Ivan - Tracker Software

Post Reply
claude vidal
User
Posts: 132
Joined: Wed Mar 09, 2016 12:47 am

"Simplified notation" value calculation: how?

Post by claude vidal » Mon Jan 21, 2019 6:52 pm

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 219 times

User avatar
TrackerSupp-Daniel
Site Admin
Posts: 2516
Joined: Wed Jan 03, 2018 6:52 pm

Re: "Simplified notation" value calculation: how?

Post by TrackerSupp-Daniel » Mon Jan 21, 2019 9:14 pm

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.
Daniel McIntyre
Support Technician
Tracker Software Products (Canada) LTD

Sales: +1 (250) 324-1621
Fax: +1 (250) 324-1623

claude vidal
User
Posts: 132
Joined: Wed Mar 09, 2016 12:47 am

Re: "Simplified notation" value calculation: how?

Post by claude vidal » Mon Jan 21, 2019 9:37 pm

Daniel,

Thanks, did the job.

User avatar
TrackerSupp-Daniel
Site Admin
Posts: 2516
Joined: Wed Jan 03, 2018 6:52 pm

Re: "Simplified notation" value calculation: how?

Post by TrackerSupp-Daniel » Mon Jan 21, 2019 10:27 pm

:D
Daniel McIntyre
Support Technician
Tracker Software Products (Canada) LTD

Sales: +1 (250) 324-1621
Fax: +1 (250) 324-1623

Post Reply