Question
NJ State Judiciary
US
Last activity: 14 Jan 2016 13:22 EST
How to allow user to input date in the format MMDDYYYY
We have a larger End User Group who are used to key-in the date values in the format MMDDYYYY (Ex: 10102015). What's the easiest way to achieve this? As we all know PRPC OOTB validation for date format kicks-in immediately and the filed will be marked with red 'X'.
With regular Date type property, MMDDYYYY will be treated as incorrect date format and system prompts with this error message "10102015 is not a valid date value" (as an example)
I've tried configuring an action-set OnChange-RefreshSection (with a Data Transform) to format. This is not converting the value rather set's the property value to 01/01/1970, while still throwing the above error (this error just flashes before the property value is set to 01/01/1970; meaning the value is blanked out after the OOTB validation for date format is triggered).
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
NJ State Judiciary
US
Thanks everyone for your inputs. I am able to achieve this using the initial approach I tried (Text Property with 'Date time' control and an Action-Set: Change/RefreshSection-With a Data Transform as parameter). In the Data Transform I used few RUF's to transform the date value to take care of the input in the format MMDDYYYY and also the date input using Calendar Control. Both are working fine now.
Pegasystems Inc.
IN
I believe this validation will always be enforced since it's a property type validation. One solution could be used one text input property for getting input and the actual date property could be declaratively populated.
Pegasystems Inc.
US
Client-side validation is a rabbit hole I've been down a few times. I was able to make a little bit of progress, but not much. I hope that the following is useful and puts someone else on the right path to a solution. This was done in 7.1.8.
Pega automatically adds client-side validation to certain controls in pega_validators.js. After a bit of digging I found that both csvalid and pzHarnessInlineScripts contain an array "datetime_patterns" which contains allowable formats. Since both of these are marked Final as well I added the following to UserWorkForm:
<script type="text/javascript"> datetime_patterns.push("MMddyyyy"); </script>
This allows the client-side validation to pass so the user is not prompted with an error immediately. However, if the user tries to save, submit the form, or if the "Display value using read-only formatting" option is checked on the pxDateTime control, the same error occurs. There is likely some internal functionality similar to datetime_patterns that is being validated against on the server side. I'm afraid I don't know how to find what that might be but I hope someone else can chime in with more info.
NJ State Judiciary
US
Thanks Mark. I tried adding the script to userworkform (pega 7.1.7) and it's not suppressing the OOTB data type validation. Am I missing something? or this works with version starting 7.1.8?
Updated: 14 Jan 2016 13:22 EST
Pegasystems Inc.
US
Just a side note ... not sure if it will help ...
The YYYY is for "week year" and technically, today is in the fiscal year 2016. You should always use "yyyy".
Also, DD is "day of the year" and should be used in 3's (DDD), not day of the month. For that, use "dd".
Pegasystems Inc.
IN
would it be convincing to attempt a custom control or edit-input with the desired format as input? please share your thoughts/comments, Thank you!
Accepted Solution
NJ State Judiciary
US
Thanks everyone for your inputs. I am able to achieve this using the initial approach I tried (Text Property with 'Date time' control and an Action-Set: Change/RefreshSection-With a Data Transform as parameter). In the Data Transform I used few RUF's to transform the date value to take care of the input in the format MMDDYYYY and also the date input using Calendar Control. Both are working fine now.
Pegasystems Inc.
IN
Awesome