Expand my Community achievements bar.

How to create a Date or time field that automatically saves current date or time?

Avatar

Level 2

hello,

i want to know that how to create a Date/Time field that automatically shows current Date/Time when .pdf form is opened.

also want to how to stop user to give input in Date/Time field

currently im putting a Date field but it is accepting user input.

hoping for quick response

Thanks in advance!

5 Replies

Avatar

Level 10

You can place the below code in the initialize event of the field to display the current date and time.

Set the language to FormCalc.

You can play around the formats to get the desired format of date and time.

if($.rawValue eq null or $.rawValue eq "") then

$.rawValue = Concat(Num2Date(Date(), "MM/DD/YYYY")," ", Num2Time(Time(), "h:MM:SS A"));

endif

You can not restrict the input area in Date time field instead you can validate the input while existing the field.

(OR) set the field to either readOnly or protected mode.

Thanks

Srini

Avatar

Level 2

but the problem is when i edit half filled form

it keeps the date and time when first it was filled!

i want it to save the date/time when it was last time saved/edited.

Avatar

Level 10

Every time you save the form, assign the current date and time again to the same field.

That way it will retain the last saved date and time.

Thanks

Srini

Avatar

Level 2

how to assign current date/time when the field is already filled with earlier date/time?

please let me know step by step instructions!

thanks

Avatar

Level 10

In your Save/ Submit button click event, place the following code to populate the date and time..

Use FormCalc as the language..

     DateTimeField1.rawValue = Concat(Num2Date(Date(), "MM/DD/YYYY")," ", Num2Time(Time(), "h:MM:SS A"));

     You can use rawValue property of the field to assign value at any time.

Thanks

Srini