Posted: 28 Dec 2015 19:13 EST 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).
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.
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:
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.
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.