Discussion
Pegasystems Inc.
US
Last activity: 18 Nov 2023 12:30 EST
How to enter a date time input with a second precision in Traditional UI
Entering a date time input in Traditional UI does not support entering the time in seconds or milliseconds since you usually don't need this kind of precision. While is it possible to see a date time with seconds precision as a read-only field - it is not possible to enter such value in a form,
The purpose of this document is to explain how to achieve this functionality by using a custom control that would leverage the html5 date time input - setting different values on the 'step' attribute of the input field allows to expose the second or millisecond precision
To use this custom control, import the RAP file attached to this post - the RAP contains 2 rules stored in the 'DateTimeDemo' ruleset - you can copy and resave these 2 rules in your application ruleset layer
- DateTimeWithSeconds is a custom control that you will use in your section rule
- DateTimeWithSeconds.js is a JS file that will be automatically loaded by the control.
The custom control supports field level validation (required, valid date time format) as well as setting a default value. Error validation on submit is also supported.
The custom control exposes one parameter called 'precision' - set this parameter to 's' to show the seconds precision or 'ms' to show the milliseconds precision.
If you are using Firefox, you can paste a value into the field if you format the value as '2017-01-11T12:13:14.112'
This ruleset was tested on a Pega Platform 8.8 version with Theme-cosmos 4.0 - this custom control should work fine on older releases and on UI-Kit.