These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Calculated dates

1josha
Registered: Apr 24 2007
Posts: 18

I am creating a form designed to assist staff to estimate the milestone dates for a defined process. The form allows users to enter a start or end date for the process, an a calculation script is supposed then populate a set of date fields to show the date by which each milestone must be completed. The dates are cacluated by summing the a defined number days from one milestone to the next. The number of days is provided by a locked numeric field. I have some radio buttons that allow the user to decide whether they will work forward or work backwards to produce the timeline.

I am using formcalc scripts on the calculate event of each date field to actively determine the dates. The script is something like:

//To keep the date fields tidy until a selection is made:
If ( Main.Checkbox1.isNull and Main.Checkbox2.isNull and Main.StartDate.isNull and Main.EndDate.isNull ) then
$ = "'
//Calculate the date:
Elseif ( Main.Checkbox1 = 1 ) then
$ == Num2Date((IsoDate2Num(Main.StartDate) + Main.NumField1), "DD/MM/YYYY")
Else
$ == Num2Date((IsoDate2Num(Main.EndDate) - Main.NumField9), "DD/MM/YYYY")
End if

On the first and last date fields, the date is just the start or end date depending on whether the user is work the dates forward or backward. The date and numeric field references are varied so that the script for each date field refers the the field before (or after) it as a starting value for the calculation.

Here is the problem. This the first and second date fields will calculate based on my script, every field after that only provides the epoch plus whatever number of dates are in the relevant numeric field. For some reason, the script returns a null value when getting a date from a field that has been calculated.

Any clues?

One option that I have considered is creating some hidden fields to tally the days in and then base all of my calculations on the start/end date (i.e. not the field before/after the current date). However, I would still like to know what is causing my problem.

For you interest, when I get past this hurdle, I am going to add a line of code to each calculate event after the "endif" that determines whether the date calculated is a working day. If it is not, the that date will be recalculate that date to the next weekday in the future (or past). I plan to use the day number reference to get this to happen. The other issue is that the last day must fall on a Monday. I plan to use the day number reference to deal with this issue too.

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
The syntax should look more like this:
You have to use the "formateValue" property, to calculate the dates.

$ = Num2Date(Date2Num(Main.StartDate.formattedValue, DateFmt(2)) + Main.NumField1.rawValue, DateFmt(2))
Sample:
https://share.acrobat.com/adc/document.do?docid=f2a0434c-35b5-4251-aacf-161bf9a8c40d

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

1josha
Registered: Apr 24 2007
Posts: 18
I thought that I didn't need the formatted string because isodate2num took any valid date string. I will give this a go. Thanks.