Week End Date calculates dates in table issues

mlstechwriter71

14-04-2014

Greetings All,

I'm working on a LiveCycle Designer ES4 document that has a Week Ending Date MM-DD-YYYY (which need to always be a Saturday) selected in a subform.

I need this Week End Date to then calculate and display the selected Saturday and the previous days in a seperate subform with a table. The days need to display in seperate columns below the header.

sample.png

This is what I have so far:

TopmostSubform.Page1.Requestor.WeekEndDate::exit - (FormCalc, client)

var endDate = Date2Num($,"MM-DD-YYYY")
var dayOfWeek = Num2Date(endDate, "E")

if (dayOfWeek <> 7) then
   xfa.host.messageBox("Ending date must be a Saturday")
   $ = null
   xfa.host.setFocus("$")
endif

Page1.#subform[1].InputTable.Row1[0].Date7 = Num2Date(endDate - 0, "DD")
Page1.#subform[1].InputTable.Row1[0].Date6 = Num2Date(endDate - 1, "DD")
Page1.#subform[1].InputTable.Row1[0].Date5 = Num2Date(endDate - 2, "DD")
Page1.#subform[1].InputTable.Row1[0].Date4 = Num2Date(endDate - 3, "DD")
Page1.#subform[1].InputTable.Row1[0].Date3 = Num2Date(endDate - 4, "DD")
Page1.#subform[1].InputTable.Row1[0].Date2 = Num2Date(endDate - 5, "DD")
Page1.#subform[1].InputTable.Row1[0].Date1 = Num2Date(endDate - 6, "DD")

However I keep getting an error on the WeekEndDate when selecting a Saturday.

Does anyone have any idea what I'm doing wrong?

Thank you for any help!

-Michelle

Accepted Solutions (1)

Accepted Solutions (1)

mlstechwriter71

17-04-2014

Well, I never got an answer from the forum here, but to help out others - here is what I did:

This was all done in FormCalc.

The object WeekEndDate Date/Time Field has a set pattern date{MM/DD/YYYY} in the Object Field Pattern in LiveCycle.

BUT, the Scripting required the pattern to be YYYY-MM-DD

Why? I have no flipping clue. It won't work any other way for me.

Also this item requires a Saturday Date to be chosen. Days of the week are designated by numbers (Sunday = 1, Monday = 2, etc.)

The line <>7 means that if the day is not Saturday (7) then the error message "Ending date must be a Saturday" will appear.

This is the Exit event Script:

TopmostSubform.Page1.Requestor.WeekEndDate::exit- (FormCalc, client)
var endDate = Date2Num($,"YYYY-MM-DD")
var dayOfWeek = Num2Date(endDate, "E")

if (dayOfWeek <> 7) then
     xfa.host.messageBox("Ending date must be a Saturday")
     $ = null
     xfa.host.setFocus("$")
endif

The individual Date cells are set to a Date/Time Field with no pattern set in the Object Field Pattern in LiveCycle.

The coding below designates a MM/DD pattern.

Each individual field has it's own scripting, with the appropriate minus calculation  - #

This is the Calculate script for the Sunday cell:

TopmostSubform.Page1.#subform[1].InputTable.Row1[0].Date1::calculate - (FormCalc, client)
var dateNum = date2num(TopmostSubform.Page1.Requestor.WeekEndDate.formattedValue,"MM/DD/YYYY") - 6
$.rawValue = num2date(dateNum,"MM/DD")

And the Saturday cell, that needed to display the Saturday End Date has the following Script, with NO minus number:

TopmostSubform.Page1.#subform[1].InputTable.Row1[0].Date7::calculate - (FormCalc, client)

var dateNum = date2num(TopmostSubform.Page1.Requestor.WeekEndDate.formattedValue,"MM/DD/YYYY")

$.rawValue = num2date(dateNum,"MM/DD")

SampleItem.png

Why did I include this all here?

Because this whole project has been gawd-awful, and hopefully these insights can help another struggle forms designer understand the FormCalc scripting used.

-M

Answers (0)