SAP Knowledge Base Article - Public

3509509 - Custom Date Format in Templates

Symptom

How to change the Date Format displayed in Templates?

Environment

SAP Sales Cloud and SAP Service Cloud Version 2

Reproducing the Issue

  1. Go to Cases Workcenter.
  2. Open a Case 123 (where 123 is the Display ID of Case).
  3. Click on Send Email.
  4. In the Email Editor, click on 'Add Template'.
  5. 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.

  1. Configurations specifying “Format” and “Locale” -
    The admin can maintain various configurations at the beginning of HTML file in the below format:

    {{templateConfiguration
    name=’<CONFIGURATION_NAME>’
    value=’{
            "locale": "<LOCALE>",
            "format": "<FORMAT>",
            "timeZone": "<TIME_ZONE>"
    }’
    }}

    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.

  2. 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

Product

SAP Sales Cloud and SAP Service Cloud Version 2 all versions