Expand my Community achievements bar.

SOLVED

Calculated Field Questions

Avatar

Former Community Member

I have a basic form that requires 2 dates to be entered - a from date and an end date.  However, the end date is always 10 days after the from date.  Therefore, the user really need only enter the from date and then the form itself should calculate and display the end date as from date plus 10.  How does one go about doing this?  I am new to these forms but did evidently setup a 'calculate' script on the end date field (language='formcalc', run at='client', script='FromDate+10').  However, what I get in the end date field is a number (ie: 10 when FromDate is blank).

Another problem I am having is that calculated fields on the form do not seem to calculate when the form is opened in Reader (Adobe Reader 9).  Actually, sometimes when previewing the form in Acrobat the fields don't calculate either.  Is it not possible to have fields calculated for those using the form in Reader?

Any advice is greatly appreciated.  Thank you.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Ok,

the problem it the picture clause.

My one was "DD.MM.YYYY" but you use "YYYY/MM/DD".

Change the script into:

if (FromDate ne null) then

     $ = Num2Date(Date2Num(FromDate.formattedValue, "YYYY/MM/DD") + 10, "YYYY/MM/DD")

endif

View solution in original post

13 Replies

Avatar

Level 10

This script in the layoutReady:event of the field "EndDate" should to the trick

$ = Num2Date(FromDate.formattedValue + 10, "DD.MM.YYYY")

Avatar

Former Community Member

This is great, I am now getting something showing in the field.  However, not the value I was expecting.  In particular, when you open the form (before you put any value into the 'from date') the 'end date' shows as 10.01.1900.  So, it is a date which is good.  Then when I enter a date into the 'from date' field (say Dec 21, 2010), the 'end date' does not change.  It just remains as 10.01.1900.

Avatar

Level 10

Hm ok,

try this script.

I tested it and it works as exspected

$ = Num2Date(Date2Num(FromDate.formattedValue, "DD.MM.YYYY") + 10, "DD.MM.YYYY")

Avatar

Former Community Member

I get the same result with this one - just shows as 10.01.1900

Avatar

Former Community Member

This sample does work for me (if i enter the first date, then the second date is calculated and displayed) if I open it in Acrobat.  However, if I use Reader it does not work (doesn't calc/show the end date).

I have put the 'script' code from the sample into my form (complete with the if statement).  If I open the form with Acrobat it does show the end date, however, it is still '10.01.1900'.  There must be something going on with my form that is stopping it from correctly calculating.  Also, the other issue i'm having is that calculated fields won't show anything if the form is opened with Reader.

Avatar

Former Community Member

I'm sure I can - will just have to figure out how/where to do that.  I assume there is an area on the adobe forum site for this?

Avatar

Level 10

Use Acrobat.com or another file hoster service and add post the link.

Avatar

Correct answer by
Level 10

Ok,

the problem it the picture clause.

My one was "DD.MM.YYYY" but you use "YYYY/MM/DD".

Change the script into:

if (FromDate ne null) then

     $ = Num2Date(Date2Num(FromDate.formattedValue, "YYYY/MM/DD") + 10, "YYYY/MM/DD")

endif

Avatar

Former Community Member

Great,  I have made the adjustments as you suggest and the end date field does now calc and display the expected date,  However, the calc field still does not work when the form is opened in Adobe Reader (it only works if opened in Acrobat).  Do you know why this is the case?  I have changed and reuploaded the file which is at...

https://acrobat.com/#d=udOH9dod3KmX2*756Xj0QA

Avatar

Former Community Member

I just found the answer to why the form did not calc/display fields in Adobe Reader.  You have to ensure that javascript is enabled within your Adobe Reader application (under preferences).  Pretty obvious thing.  Guess I wasn't smart enought to find it earlier.  Thanks.