Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Adding 30 days to a date in a dynamic LC form

Avatar

Level 2

Hello-
I'm working on a dymnamica form that is merged with XML data. In the XML, I get a FirstQuoteDate and bind it to the corresponding field in the form. I then have to calculate the ValidDate by adding 30 days to the FirstQuoteDate and display that date int he Valid Date field.
I've tried several scripts with no luck. Below is the latest script I tried. I also tried the script in several different events. I believe it is the calculate event for the ValidDate field right now. Does anyone know what I am doing wrong?

var QuoteDt = Date2Num(PROPOSAL.Page2Summary.FirstQuoteDate.rawValue, "MM/DD/YY")
var FutureDt = QuoteDt+30
var ValidDt = Num2Date(FutureDt, "MM/DD/YY")

PROPOSAL.Page2Summary.ValidDate.rawValue = ValidDt

1 Accepted Solution

Avatar

Correct answer by
Level 10

Here is the updated form.

https://acrobat.com/#d=rbDELbBJM-v3O2J1pNddoA

Since I do not have the XML file that is used to populate the PDF, I do not know how the date format could be..

So in the form I tried using the format "YYYYMMDD" ("20101020").. That means my input value for the date in the XML will come in that format.

Then your code also you need to change the format for the rawValue accordingly.

ValidDate.rawValue = Num2Date(Date2Num($.rawValue, "YYYYMMDD")+30,"MM/DD/YYYY");

The other thing you did was set the language to JavaScript.. But the above function will work with FormCalc.

For your testing, I made both the fields as visible instead of hidden.. After you verify, you can set them hidden.

Let me know if you have nay issues..

Thanks

Srini

View solution in original post

10 Replies

Avatar

Level 10

Here is a sample form..

https://acrobat.com/#d=TraLCmZ-W5yvgAvZaMNP9Q

You can verify the patterns for the date fields in properties..

Thanks

Srini

Avatar

Level 2

What event should I be putting this script in? Am I thinking I can't put it in the Change event because the date isn't being entered through the form so the field never actually changes? Do I have to use a different event? The FirstQuoteDate and ValidDates are actually floating text fields in my form. I did find that example out there from a different discussion and have tried this script in the initialize event of the First QuoteDate field and it didn't work for me.

ValidDate.rawValue = Num2Date(Date2Num(xfa.event.newText, "M/D/YYYY")+30,"MM/DD/YYYY");

Avatar

Level 10

If you are trying in the initialize event, then change the code little bit..

ValidDate.rawValue = Num2Date(Date2Num(this.rawValue, "M/D/YYYY")+30,"MM/DD/YYYY");


Try this and let me know.. If you still have issues, you can send it to LiveCycle9@gmail.com, so I can have a look at it..

Thanks

Srini

Avatar

Correct answer by
Level 10

Here is the updated form.

https://acrobat.com/#d=rbDELbBJM-v3O2J1pNddoA

Since I do not have the XML file that is used to populate the PDF, I do not know how the date format could be..

So in the form I tried using the format "YYYYMMDD" ("20101020").. That means my input value for the date in the XML will come in that format.

Then your code also you need to change the format for the rawValue accordingly.

ValidDate.rawValue = Num2Date(Date2Num($.rawValue, "YYYYMMDD")+30,"MM/DD/YYYY");

The other thing you did was set the language to JavaScript.. But the above function will work with FormCalc.

For your testing, I made both the fields as visible instead of hidden.. After you verify, you can set them hidden.

Let me know if you have nay issues..

Thanks

Srini

Avatar

Level 2

Sounds great. Thank you so much for your help. I'll take a look at it right away.

Becca

Avatar

Level 2

Hello-

I have another question if you don't mind. In the same form, in the Auto section, I have two subforms (actually a table and a subform) that have to be bound to the same repeating tag tag.

I'm having a problem with the second item (whether is it the table or the subform) showing any information.

It seems like only the first item that is bound to the tag gets populated with data. Is it possible to bind two items to the same XML tag? Is there something I need to be doing different? Let me know if you'd like to see the form and the XML.

Thanks,

Becca

Avatar

Level 10

Please send the form and XML so I can check it..

Thanks

Srini

Avatar

Level 2

Hi Srini-

Here is an updated copy of my form and the XML as I have been doing some work on it today. The problem is on Page6Auto with the VehiclesList and the VehicleSchedule.

Thanks again,

Becca

Avatar

Level 2

Hi Srini-

Just wanted to let you know I figured out my form and got it working. I used a subform set for my problem table and subform.

Thanks,

Becca