Autocalculate EndDate - 18 months minus 1 day from StartDate

Community Beginner ,
Mar 26, 2020

Copy link to clipboard

Copied

I have already a lot of different pdf forms used to register learners as they start their apprenticeship with my company. Different programs mean different length. 

 

Long story short, I have this idea to make the form more convenient where people feed in information like "Learner's name", "Coach", Start Date", choose the programme from the drop down list and click a button and corresponding forms are generated. I am using Adobe Livecycle. However, I got stumped on calculated date field. 

 

1. How do I calculate the EndDate of 18 months minus 1 day from the StartDate. I tried using the script that works on Adobe Acrobat Pro for my current forms but for some reason it doesn't work in Adobe LiveCycle. I have a StartDate field for people to input the info and EndDate field is automatically calculated.

 

var date= util.scand("dd/mm/yyyy", this.getField("StartDate").value);
date.setMonth(date.getMonth()+18)
date.setDate(date.getDate()-1)
if (this.getField("StartDate").value!="")
{
event.value=util.printd("dd/mm/yyyy",date)
}
else
{event.value=""}

 

2. My second question is if I have different lengths of programs of 13-18 months, how do I improve the script to reflect that?

 

Many thanks in advance

Thao

TOPICS
Acrobat SDK and JavaScript, PDF forms

Views

74

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Most Valuable Participant ,
Mar 26, 2020

Copy link to clipboard

Copied

Why are you using LCD? It makes things much more complicated, and is supported on far less systems.

Unless there's a really good reason I would strongly suggest switching to a "normal" Acrobat form.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Mar 26, 2020

Copy link to clipboard

Copied

I want to create an interactive form .i.e Coach picks Progamme and company size and the corresponding pages appear. Ca this be done with Adobe Acrobat Pro? I used Lifecycle to create a registration form with buttons to add or remove lines and fields hidden which only appear based on what radio button is checked. That's what gave me the idea to make this master form. 

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Most Valuable Participant ,
Mar 26, 2020

Copy link to clipboard

Copied

Yes, it's possible in an Acrobat form, although in a more limited way, since you can't "re-flow" the entire page. You can show/hide fields, or even pages. If you hide a field there will just be an empty spot where it was located, unless you move other fields to take its place.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Mar 26, 2020

Copy link to clipboard

Copied

That's why I want to give Livecycle a go. But I mean is there a reason the Javascript above works in Adobe Pro but doesn't work in LCD? It just drives me mad because I couldn't tell where the problem lies. 

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Most Valuable Participant ,
Mar 26, 2020

Copy link to clipboard

Copied

LCD uses a different scripting model than Acrobat. While the core syntax is the same the way you access fields and maybe even the util object are different. I can't help you beyond that, I'm afraid.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
Mar 26, 2020

Copy link to clipboard

Copied

In XFA forms the "this" keyword refers to the current field object, not the document. And the result of a calculation is simply the last value in the calculation script. If the value is being set from a non-calcualtion, then it is set with the "rawValue" field property.  

 

So, very different scripting rules. You should read about them if you're going to script in an XFA doc. 

Likes

Translate

Translate

Report

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