When displaying a date property in the UI, the presentation tab of the control has a Date Format dropdown. This is populated with around 10 date formats that are provided OOTB. It also provides a Custom option, where you can then enter your own format, like 'MM-dd-yyyy'.
'MM-dd-yyyy' is the preferred format of dates by our client. It would be great if we could add this to the drop down, naming it ClientFormat or something... This would make it reusable for our developers for any date controls, and if the preferred format was to change, it would be great to make the change only in one place.
Is it possible to add a new format to the dropdown? If not can we please submit this as an enhancement request?
To have any custom date format you have to choose 'Custom' from the dropdown and then provide the format. I do not think it is possible to add the custom formats to Pega's dropdown list as those rules are final and cannot be modified.
Posted: 7 months ago
Updated: 7 months ago
Posted: 8 Feb 2021 22:28 EST Updated: 8 Feb 2021 23:05 EST
Braam Smith (BraamCLSA)
Partner Success Tech Lead - APAC
The good news: You can add a new format to the drop-down:
Ruleset-specialize the Property rule Embed-Control-Mode.pyDateTimeFormat
Add the new format(s) to the Prompt Value items, where
Standard value is the date format you want to apply [MM-dd-yyyy]
Prompt value is the label to appear in the drop down [e.g. Month(2)-Day(2)-Year(4)]
All Date/Time fields will then show the new option and allow it to be selected:
Which then has the desired effect at runtime (Feb 9, 2021):
The bad news? From the above example, the Standard value is what is stored in the rule instance as the desired format for the output. If the preferred format was to change, changing the Standard value of your new format in pyDateTimeFormat would take effect for all new Date/Time fields you configure going forward.
However all existing Date/Time fields set to the previous preferred format would remain unchanged, still saying "MM-dd-yyyy" in their instance of the rule, and applying that format at runtime. So, unless there is some extension point in the DateTimeUtils.formatDateTime API that the pxFormatDateTime function channels into, you don't get the configure-once-apply-everywhere outcome that you were hoping for. And it would need an enhancement to provide.
Use the Share an Idea feature in Collaboration Center to propose an enhancement.