Custom format dateTime property in correspondence

Hi,

I’m trying to format a DT-property as “dd/MM/yyy” in my correspondence rule.

Currently in the connector to the “Send email” block, I set a param.TempDate as @FormatDateTime(.DateProperty,“dd/MM/yyyy”,“”,“”) and use the param.TempDate as a pxDisplayText reference in my correspondence rule.

This is working, but probably far from an ideal solution.

I’m able to call the FormatDateTime function directly in jsp, but then, the difficulty is how to get the propertyvalue passed as a parameter to this function. I don’t want to refer hardcoded to pyWorkPage page, it should read the property from the current context.

Looking forward to your feedback!

@Joris Claus You can use a parameterized reference in your correspondence rule to achieve this. First, create a parameter in your correspondence rule, for example, ‘ParamDateProperty’. Then, in the connector to the ‘Send email’ block, set the parameter value as the property you want to pass, like .DateProperty. In your correspondence rule, use the following syntax to format the date:

<pega:reference name=“.ParamDateProperty” format=“dd/MM/yyyy”/>

This will format the date according to the ‘dd/MM/yyyy’ format and use the property value passed from the current context without hardcoding the pyWorkPage reference.

This answer came from a Pega gen-AI assistant using the below references. As a Support Center moderator, I reviewed the answer and references for accuracy:

I want to populate current year (only year) in a correspondenced.

Include current date in paragraph rule

Incorrect Date to date time property conversion

@Joris ClausMaybe the following code snippet will help you, where the @DateTime.FormatDateTime() function is used to format a dateTime:

<pega:save name="hakunaMatata" ref="$THIS.myDateTimeProperty" />
<%= pega_rules_datetime.FormatDateTime(tools.getSaveValue("hakunaMatata"),"dd.MM.yyyy","","") %>