Symptom
How to change the Date Format displayed in Templates?
Environment
SAP Sales Cloud and SAP Service Cloud Version 2
Reproducing the Issue
- Go to Cases Workcenter.
- Open a Case 123 (where 123 is the Display ID of Case).
- Click on Send Email.
- In the Email Editor, click on 'Add Template'.
- Select a Template from 'Template Selection Quick View'.
Notice that the Date field value is always displayed in UTC Timezone in format YYYY-MM-DD HH:MM:SS.MS.
Resolution
To support different date formats in a template, the system administrator can upload the template content maintaining few details.
- Configurations specifying “Format” and “Locale” -
The admin can maintain various configurations at the beginning of HTML file in the below format:{{templateConfiguration
This indicates that wherever user wants the date to be formatted according to the format "<FORMAT>", the locale "<LOCALE>", and the time zone "<TIME_ZONE>", they can use this configuration.
name=’<CONFIGURATION_NAME>’
value=’{
"locale": "<LOCALE>",
"format": "<FORMAT>",
"timeZone": "<TIME_ZONE>"
}’
}} - Placeholders for date fields specifying one of the above configurations -
The maintained configurations can be used against a date placeholder in the following manner:{{<DATE_FIELD> =’<CONFIGURATION_NAME>’}}
This indicates that the date in "<DATE_FIELD>" will be formatted according to the configuration maintained in ‘<CONFIGURATION_NAME>’
Example:
{{templateConfiguration
name="firstDateFormat"
value= '{
"locale": "de",
"format": "d MMMM yyyy"
"timeZone": "Europe/Berlin"
}'
}}
<html>
<body>
<p> DateFormat Scenario</p> <br>
{{formatTemplateDate adminData.createdOn configurationName="firstDateFormat"}}<br>
</body>
</html>
Expected Output for above example:
DateFormat Scenario
4 Juni 2024
NOTE: This code is applicable only for the Date Time fields which are in format YYYY-MM-DD HH:MM:SS.MS.
Keywords
Date Format, Timezone, Template, Email, Custom, UTC, Locale, Time , KBA , CEC-CRM-TMP , Templates for SAP Sales/Service Cloud , CEC-CRM-CAS , Case Management for SAP Sales/Service Cloud , CEC-CRM-APT , Appointment for SAP Sales/Service Cloud , CEC-CRM-EML , Emails for SAP Sales/Service Cloud , How To
SAP Knowledge Base Article - Public