Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

Extremely novice question regarding entry of current date

Avatar

Not applicable
Using LiveCycle v. 8. Just want a field to display the current date when the form is opened.



The field type is date/time. When selected, I have the script bar set to "DocReady" as the event and script language = FormCalc. Can't figure out what to put in the script line to make the field display the date.



Thanks for any help.
0 Replies

Avatar

Not applicable
Hi Rob,



Place the following script in the "layout:ready" event. script laguage = JavaScript.



var months = new Array ("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12");



var now = new Date();

var yyyy = now.getYear() + 2000 - 100;

var mm = now.getMonth(); mm = months[mm];

var dayNumber = now.getDate();

var dd;



if (dayNumber < 10)

{dd = "0" + dayNumber;}

else {dd = dayNumber;};



if (this.rawValue == null) this.rawValue = yyyy + "-" + mm + "-" + dd;



trust this will help.



Regards,



Chris Fourie

www.intelliform.co.za

Avatar

Not applicable
Thank you Chris, but when I follow your instructions and paste in the code, my text box still doesn't display the date. No doubt I'm missing something.



Rob

Avatar

Not applicable
Hi Rob,



send your email addres to chris.fourie@intellifrom.co.za and I will send you a sample form.



Regards,



Chris Fourie

www.intelliform.co.za

Avatar

Not applicable
Hi Rob,

You can retrive current date and time using FormCalc. However date and time functions are separate in FormCalc, so that you have to concat date and time after retrive.



Concat(Num2Date(Date(), "YYYY-MM-DD"), " ", Num2Time(Time(), "HH:MM:SS"))



this script returns the current date and time in format "YYYY-MM-DD HH:MM:SS". You can change the formats also. But it needs capital letters for format types.

Regards,

Asiye Gunaydin

Avatar

Not applicable
I have a form that has a button to add new rows to a table, and need for one of the columns to default to the current date. However, once the date has been added, I don't want it to change. Is this possible?

Avatar

Not applicable
Hi Claudia,



make the date field readonly and place this script in the layout:ready event of the date field:



var months = new Array ("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12");



var now = new Date();

//var dateFormat = util.printd("yyyy-mm-dd", now); //this works but produces an error message in the warnings window "util undefined"

//this.rawValue = dateFormat;

var yyyy = now.getYear() + 2000 - 100;

var mm = now.getMonth(); mm = months[mm];

var dayNumber = now.getDate();

var dd;



if (dayNumber < 9)

{dd = "0" + dayNumber;}

else {dd = dayNumber;};



if (this.rawValue == null) this.rawValue = yyyy + "-" + mm + "-" + dd;



Regards,



Chris Fourie

www.inteliform.co.za

Avatar

Not applicable
Chris,



I found your current date script very helpful for a form that I am putting together. Is there a way that I would be able to do the same thing with the current time? We need our form to display the current date and time, but also be editable if the form is filled in at a later date/time.



Thanks for your help,



Jason