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

Date Field formatting with action on Enter Event

Level 2
Level 2

I have placed a date/time field on a form that should show the full date

and time in the format MM/DD/YYYY HH:MM A (03/22/2012 10:05 AM) on the

enter event.

I'm having trouble finding the right combination of object properties and

scripting to display in that format. Using the action builder it will only

set the date (not time) in the format (YYYY-MM-DD), and not in the pattern

I specified in patterns on the the value tab for display and data and you

can't include the time.

If I set the field to calculated, then the field is populated on

initialize, which is not desired as the time has to be accurate to the

minute and should not be populated until the user is ready to "stamp" the

field by clicking in it.

What JS on the enter event of the field would achieve this?

Also, will the enter event still trigger if the field is read only when the

form loads?

Maybe there is a better way to achieve this without the use of a button?

3 Replies
Level 10
Level 10


You can set the format at design time by clicking Patterns in the Object > Field palette.

There is an example here for changing the format at runtime, but you probably don't need that if you set up the pattern for the date field in Designer. and

Hope that helps,


Level 2
Level 2

Thanks for the quick reply Niall,

What you are suggesting is what I already have. I need it to populate on

the enter event of the field as per the OP. Perhaps also set the field to

read only and set focus to a button.

Can't do it with action builder because there is no option to set the field

value for the current time, only the current date.

Level 2
Level 2

Your comment jogged my mind.

I got it working by putting this in the enter event on the field.

this.resolveNode("$").rawValue = util.printd("mm-dd-yyyy h:MM tt", new Date());