Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Can't get auto-populated current date & time field to show in correct way

Avatar

Level 3

I've added a "Date/Time Field" to my form. In the value tab, type is "calculated - read only". Runtime property is "Current Date/Time". 

If I go to "patterns" and select a particular type under both "display" and "data" (e.g. April 01, 2007 3:30:47 PM) and click OK, then go to the "preview PDF tab", the data is shown as "2020-08-23 10:08:17". Why isn't it showing the date & time in the way I chose?

Also, I want it to show the date & time when the user opens the form to fill it in. I don't want it to update this when I receive the form and open it to view it - is this possible?

1 Accepted Solution

Avatar

Correct answer by
Employee

@lostfrogg  If you set Runtime property as "Current Date/Time", it calls the below FormCalc script in layout:ready event of the DatatimeField. If you want to change the display pattern, you can modify it here.

 

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

 

Also, if you want to show the date & time when the user opens the form to fill it, in that case, you can write a simple Javascript for fetching the current datetime and use it in the form initialize event.

 

I hope this is helpful.

View solution in original post

1 Reply

Avatar

Correct answer by
Employee

@lostfrogg  If you set Runtime property as "Current Date/Time", it calls the below FormCalc script in layout:ready event of the DatatimeField. If you want to change the display pattern, you can modify it here.

 

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

 

Also, if you want to show the date & time when the user opens the form to fill it, in that case, you can write a simple Javascript for fetching the current datetime and use it in the form initialize event.

 

I hope this is helpful.