-
1. Re: Week End Date calculates dates in table issues
mlstechwriter71 Apr 17, 2014 12:10 PM (in response to mlstechwriter71)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("$")
endifThe 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")
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



