Highlighted

Date Field

Jannae72

15-03-2009

I am creating a timesheet for our organisation and am wondering if there is anyway that our employees only have to enter Monday's date and the following dates will automatically be generated. I have been able to do this in excel but I am not sure how to do this in Livecycle.



Your knowledge would be greatly be appreciated.



Julie

Replies

Highlighted

Steve_L_Walker

15-03-2009

Julie,



Given a form with the root name 'form1', an untitled subform, and five occurrences of a DateTimeField called 'dtf', you could add the following FormCalc script on exit event of 'dtf[0]' to calculate the next four days based upon the date selected for 'dtf[0]'.



form1.#subform[0].dtf[0]::exit - (FormCalc, client)



xfa.form.form1.#subform.dtf[1] = Num2Date((Date2Num(xfa.form.form1.#subform.dtf[0].formattedValue,"YYYY-MM-DD")+1),"YYYY-MM-DD");

xfa.form.form1.#subform.dtf[2] = Num2Date((Date2Num(xfa.form.form1.#subform.dtf[0].formattedValue,"YYYY-MM-DD")+2),"YYYY-MM-DD");

xfa.form.form1.#subform.dtf[3] = Num2Date((Date2Num(xfa.form.form1.#subform.dtf[0].formattedValue,"YYYY-MM-DD")+3),"YYYY-MM-DD");

xfa.form.form1.#subform.dtf[4] = Num2Date((Date2Num(xfa.form.form1.#subform.dtf[0].formattedValue,"YYYY-MM-DD")+4),"YYYY-MM-DD");



The FormCalc data functions work nicely because they are smart enough to cut across months and years.



Note, I have defined the display and edit patterns on 'dtf[0]' through 'dtf[4]' as date{YYYY-MM-DD}. A different (consistent) pattern would work equally well.



Steve
Highlighted

ech0

16-03-2009

HI Steve,



Complete noob here- but have similar need for a vacation request form-



my ?: can you apply the form calc you describe above to fields on a table or in separate text(date?) fields with out having to use the subforms?



Or does this calculation only work when it applies to subforms?



While i'm asking the guru- is there any way to show a calendar that only the 'sunday's' are clickable? Reason being our work week begins on a sunday, and to fill in the rest of the week, this would give the user Only sundays to choose from.



TIA



eric
Highlighted

Jannae72

16-03-2009

Thanks Steve,



I have nearly to it to work using the following scripting:



form1.#subform[0].Table2.Row2.Cell2::exit - (FormCalc, client)



xfa.form.form1.#subform.Table2.Row2.Cell3 = Num2Date((Date2Num(xfa.form.form1.#subform.Table2.Row2.Cell2.formattedValue,"YYYY-MM-DD"))+1,"YYYY-MM-DD");

xfa.form.form1.#subform.Table2.Row2.Cell4 = Num2Date((Date2Num(xfa.form.form1.#subform.Table2.Row2.Cell2.formattedValue,"YYYY-MM-DD"))+2,"YYYY-MM-DD");

xfa.form.form1.#subform.Table2.Row2.Cell5 = Num2Date((Date2Num(xfa.form.form1.#subform.Table2.Row2.Cell2.formattedValue,"YYYY-MM-DD"))+3,"YYYY-MM-DD");

xfa.form.form1.#subform.Table2.Row2.Cell6 = Num2Date((Date2Num(xfa.form.form1.#subform.Table2.Row2.Cell2.formattedValue,"YYYY-MM-DD"))+4,"YYYY-MM-DD");



The only problem that I have now is that when Monday's date is entered eg 16-Mar-09, Tuesday's date is 01-Jan-00 and so on. How do I make Tuesday's date follow on from the 16-Mar-09 eg 17 Mar-09?



Regards

Julie
Highlighted

Steve_L_Walker

16-03-2009

Eric,



The form hierarchy always includes a subform. When you generate a new blank template you will see '(untitled Subform) (page 1)' in the form hierarchy. In this case the page is a subform. A form is typically constructed with multiple subforms on a page. Depending on the complexity of the form you may have subforms nested in subforms.



It is possible to access an object without the subform name and apply calculations, such as the FormCalc date function. Whether or not it yields predictable results in all circumstances depends upon the form. There are different ways to access objects in scripts and they are documented here:



http://livedocs.adobe.com/livecycle/8.2/acrobat_designer/001157.html



On the DateTime object, it is not possible to customize the dates exposed in the widget. It would be possible to derive the current date, work back to Sunday, and populate date fields for the week, however.



Steve
Highlighted

Steve_L_Walker

16-03-2009

Julie,



The display and edit patterns on your table are not consistent with the formattedValue in the function call. You have the patterns defined as date{DD-MMM-YY}. The pattern on the function is date{YYYY-MM-DD}.



You can either change the pattern on the function call to DD-MMM-YY or you can change the display and edit patterns on the table to YYYY-MM-DD.



Steve
Highlighted

Avatar

Guest

17-03-2009

Is it somehow possible to ask, if a date is in some kind of range?

F.ex. a user has to send a form at least 1 month before/after an event is happening/has happened. If it is out of that range, the form should apply an errormessage.



Is it possible to compare the date he enters to the sysdate?
Highlighted

pguerett

17-03-2009

Sure ....you can use a function to channge the date into a number of days from a set point in time (called an epoch). There is a simple FormCalc function called Date2Num that will return a number of days since th eepoch. You can add a subtract 30 days from it and see if the Date2Num that the user entered is in that range.



Make sense?
Highlighted

Avatar

Guest

17-03-2009

Yep made sense 🙂

Just looked up the date formatations today and wondered what epoch really is.



Thanx ^^

(One more trick in my little trickbox. ^^)
Highlighted

ech0

17-03-2009

HI Steve-

I see says the blind man....OK, so I'll do as demonstrated, Thanks for the explanation.



One follow up ?: using the DTF object to pull a calendar date, when the object pops up and you mouse out of the box to get the pull down for the calender it fires the script -mouse out event- How do i prevent it from happening?



i changed the event to exit, but now the user has to click outside the box to get script to fire.



I apologize in advance for what prolly is a simply issue...



eric