Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

Need to set a numeric value (Late Fee) if the Current Date is past a set date.


Level 2

Need to set a numeric field (Late Fee) if the Current Date is past a set date (3/31/17).  To test in Preview mode, I was using the set date as 1/1/17.  This is for a recreational softball registration form.  If the user prints the form after 3/31/17, then the Late Fee of $10.00 will auto-populate in the Numeric Field, LateFeeCalc.

My JavaScript set on the numeric field on the initialize event (because the date is set to current date when form is opened).  There is no calculation involved.

if (Date2Num(SubFormCommands.MasterPage.PAGE2.RegistrationForm.Details.CurrentDate.formattedValue, "MM/DD/YYYY") >

Date2Num("01/01/2017", "MM/DD/YYYY") then $=10

I have tried to tweak this several ways and received a variety of syntax errors surrounding the then portion of the statement.  I have replaced the "then" with brackets but no change.  I have tried to set variables, but no change.  When I rarely received no syntax error message, the functionality simply didn't work.

PLEASE help with my code, ASAP!  I am a self-taught "noob" and have only ever worked with SQL on a very high level.

Many thanks,

6 Replies


Level 5

There are a number of things going on with your form.

I believe the biggest reason for your calculation issues is that the date field you are referencing in the Late Fee Field is below the Late Fee Field. It does not get initialized until after the Late Fee field initializes.  Form fields are processed Top-Down/Left to Right.  A way to fix this is to either have the Late Fee field calculate its own value for Current Date, or place a 'hidden' field in the form above the Late Fee, and have the Date field reference the hidden field as well.

Here is a script that should work in your Late Fee field:

var DateCurrent = util.printd("yyyy-mm-dd", new Date());

//app.alert("Date: " + DateCurrent);

var DateLate = util.printd("yyyy-mm-dd", new Date("January 01, 2017"));

//app.alert("DateLate: " + DateLate);

if (DateCurrent >  DateLate) {

    this.rawValue = 10.00;


app.alert is an easy way to get debug information on script execution.  The value in parens needs to evaluate to a string.

I believe you can find out more about it by looking at the Scripting Reference in Designer Help.

Additionally, I see that you have your form fields located in the Master Page structures.  In the future, you will not want to do this.  You should use 'page' design elements to contain the field elements in you design,  Master Pages are typically for Header/Footer and boilerplate text that is needed on each rendered page.  You can have multiple Master Pages, etc.

There used to be courseware 'Learn LiveCycle in 3 days' or something to that effect - it would walk you through the particulars of form design.

Good Luck



Level 2

Thank you Mark....that did the trick!  I was aware of the flow, but didn't know it applied in scripting.

Another related question.....is there another flaw somewhere that would cause users not to be able to save changes on the form?  As previously stated, this form is to register girls to play rec softball.  Parents are completing it and trying to save but when they close down the form and re-open it, the entries they made are gone....just a blank form.

Both Adobe Reader and Adobe Acrobat X have reportedly been used.  I understand Reader not allowing changes to be saved, but I would also think they would have received some error message explaining that fact.

I checked the Security settings on the form in Acrobat and it says no changes can be made, but when I open the security settings on the form in LC Designer, I cannot find a matching setup.  I do not want to setup password or certificate security, nor do I think I should have to.

I read this was related to a JavaScript setting somewhere....?

New link to form https://1drv.ms/b/s!AukslpvW9eo8gRotEP5uopQyPTYd


Level 5

I believe the feature you are looking for is known as "Reader Extensions".

Saving a PDF with data in it is native to a full copy of Acrobat.  The free Adobe Reader product does not have this ability out of the box.

By default, you can create PDFs that collect data, and can be printed or submitted to a LiveCycle / AEM Forms server.

In order to be able to save the PDF locally with data ( or use a number of other features ) in Adobe Reader - the PDF needs additional rights granted to it.

These can be applied by using methods on the Server, or by saving the PDF with a copy of Acrobat - using Save as Other > Reader Extended PDF > ( choose the flavor you want ).

If you are using Acrobat, there is a limit to the number of documents you can extend based on your license agreement.

This can apply as well in an enterprise environment when using the server to apply rights - again based on license agreement in place.

Good Luck, glad to hear you are making progress.



Level 2

Hi Mark....I do appreciate the time you have taken recently to help me with my project.

I hear what you are saying about Adobe Reader.  Last evening, before I posted my question, I actually already tried saving the form with data in Acrobat Pro using your basic instructions above but the path was Save As > Reader Extended PDF.  I tried all three (3) of the choices available.....None worked. 

1. Enable adding text in documents (that are not fillable forms):  Once Typewriter Tool is enabled for this document in Adobe Reader, certain functions normally available to users in Acrobat, such as editing document content, signing and inserting/deleting pages, will be restricted.  Acrobat must save the document.  Saving cannot be undone.  Would you like to continue?

2. Enable Commenting & Measuring:  Once Commenting Tool is enabled for this document in Adobe Reader, certain functions normally available to users in Acrobat, such as commenting, will be restricted.  Acrobat must save the document.  Saving cannot be undone.  Would you like to continue?

3. Enable Additional Features:   Box listing 4 features that are available when the document is opened in Free Adobe Reader.  1. Save form data   2. Commenting & Drawing mark-up tools.  3. Sign an existing signature field.  4. Digitally sign the document anywhere on the page (8.0 or later).  Once Reader Enabled for this document, these functions normally available to users in Acrobat, such as editing document content and inserting/deleting pages, will be restricted. 

I guess what confuses me the most is that I have created other PDF forms (from scratch and by converting Word docs) in which I am able to save copies of the form while retaining the keyed data.  The only difference I can think of between this one and those others is that I created this one from a template.  Would that make a difference?


Level 5


In looking at your PDF, I get the same result of data not persisting when Reader Extended.

I can tell that the extension was applied, because I do not get the prompt telling me I cannot save data in the 'Extended' version.

I think the issue may be in how the form is structured.  XDP forms separate the form and the data.  Typically they have a data schema that fields are bound to.  If a schema is not used, the the binding option of "use name (<field name>)" is selected to give the form instructions on how/where to store the data for later retrieval.

Adding binding ( along with Reader Extending ) allowed me to save and persist data in your form

This is found on the Window>Object Palette, when you have a field highlighted in Design View ( in your case you will need to be on the Master Page tab ) See my prior note about using Page Subforms


I cannot speak to importing Word Documents vs templates. but hopefully this gets you where you want to be.

Here is what the form could look like restructured - (Your first page could stay in the Master Page container as there is not editable/enterable data in it) .  Not to say that the way I restructured it was perfect, just an example.  This restructure was not required to get the data to persist.