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

LiveCycle Designer - adding days script problem

gombear
Registered: Oct 6 2011
Posts: 18
Answered

Hi,
 
I'm creating a form using LiveCycle Designer.
I have a date field called "EndDate" and "ClaimDeadLine".
On End Date exit event, i have below code.
Add 61 days to end date and populate claim date.
But, not working. Could you tell me how to fix this?
Thanks, Gombear
  
form1.#subform[0].EndDate::exit - (FormCalc, client)
 
$.rawValue = xfa.resolveNode("form1.#subform.EndDate");
 
var endDate = $.rawValue ; xfa.resolveNode("form1.#subform.ClaimDeadLine") = Num2Date(Date2Num(endDate, "MM/DD/YYYY") + 61, "MM/DD/YYYY");

My Product Information:
LiveCycle Designer, Windows
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Are you sure that the 'rawValue' is providing the date character string in the correct format?

I would use the 'formattedValue' property.

George Kaiser

gombear
Registered: Oct 6 2011
Posts: 18
Hi George,

I tried with your suggestion as below code.

$.formattedValue = xfa.resolveNode("form1.#subform.EndDate");
var endDate = $.formattedValue ; //endDate is not string format
xfa.resolveNode("form1.#subform.ClaimDeadLine") = Num2Date(Date2Num(endDate, "MM/DD/YYYY") + 61, "MM/DD/YYYY");

But, still not working.
If I enter 1/1/2011 in end date, I'm getting 03/02/1900 on claim date.
Thanks, Gombear
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Accepted Answer
Hi,

ok, in the exit:Event of the EndDate add this FormCalc script.
ClaimDeadLine = Num2Date(Date2Num($.formattedValue,"MM/DD/YYYY") + 61, "MM/DD/YYYY")
To make this work you have to set up the diplay pattern for the fiels EndDate too. Otherwise the formattedValue may be different to the format defined in the script which causes the script to fail.
date{MM/DD/YYYY}

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

gombear
Registered: Oct 6 2011
Posts: 18
Hi Radzmar,
I guess my problem is setting end date field correctly.I tried your code and it works only if I entered eaxtly matching date pattern "mm/dd/yyyy".

For "End date" field, I cleicked "validation pattern", then validation tab, selected as you suggested.
If input doesn't match MM/DD/YYYY, warning message shows even with "1/1/2011".
It have to be exactly "01/01/2011", then calculated date is correct.
I don't expect users to understand this.
Is there a way convert entered date in reseanable format to change mm/dd/yyyy behinde the form for my calculation to work?
Thank you so much Radzmar.
Gombear
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Hi,

you can use several combined patterns to allow several ways for entering the dates.
As edit pattern use:
date{MM.DD.YYYY}|date{MMDDYYYY}|date{MM DD YYYY}|date{MM-DD-YYYY}|date{MM:DD:YY}|date{MMDDYY}|date{MM DD YY}|date{MM-DD-YY}|date{MM,DD,YYYY}|date{MM/DD/YYYY}|date{MM,DD,YY}|date{MM/DD/YY}
As display pattern use:
date{MM/DD/YYYY}
This method allows the user to enter a date in this ways:
08.10.2011, 08102011, 08 10 2011, 08-10-2011, 08:10:11, 081011, 08 10 11, 08-10-11, 08,10,2011, 08/10/2011, 08,10,11, 08/10/11

All this inputs will be reformatted by the patterns into:
08/10/2011

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

gombear
Registered: Oct 6 2011
Posts: 18
Hi Radzmar,
You're The man!
Wow, I don't know how to thank you.
Thanks you so much and have a nice weekend!
Gombear
dmitchell
Registered: Oct 17 2011
Posts: 2
Hi Radzmar, my users need to do something similar with the date. One field accepts a date, and the other displays an expiration date calculated a few days out from the date in the first field. The code for this works fine like you have it above.
The problem is that the users want to be able to click the Enter or Tab key to get to the next field, and that's where the problem comes in. When they do this, the expiration date doesn't appear. How do I allow them to just enter the date in the first field, click the Enter or Tab key to get to the next field, and show the expiration date? Right now the expiration date does show up, but only if they use the date picker on the first field. Thanks for any help!!!
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Not sure what's going in your form.
If the script above is put into the exit:Event of the field, it doesn't matter how you exit the field (tab, mouse action or script).
When the field looses the focus the exit:Event is fired and so the script.
Maybe another script is affecting this script in some way ... but I'm just guessing.

Can you share your form (at acrobat.com for example), so I can look at it?

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

dmitchell
Registered: Oct 17 2011
Posts: 2
I was thinking that it should, too, but something you said about another script clicked in my mind, so I went back to check it out, and now the form is working as it should. Thanks for your help!