sahincelik
(Sahin Celik)
February 13, 2025, 3:04pm
1
Hi everyone,
I’m trying to modify the date format in some email templates, but it seems that no matter what I do, the changes aren’t taking effect. Specifically, in the “Access Request for Self” email template, I formatted the date as follows, yet the email still displays it in this format: Mon Feb 17 23:00:00 UTC 2025 .
Is there something I might have missed? Any insights would be appreciated.
Thanks!
#foreach ( $type in ${requestedObjectDetailsByType.keySet()} )
#foreach ( $detail in ${requestedObjectDetailsByType.get($type)} )
${detail.name}
#if ($detail.removeDate)
De rol wordt ingetrokken op ${spTools.formatDate($detail.removeDate, “MM/dd/yyyy HH:mm”)}
#end
#end
#end
Hi Sahin,
Incase you need to change the date format, it can be done in two steps.
Convert the incoming date string to a date object
Format the date object to the desired string
For example, if you have a variable named $removeDate
which is a string that looks like this:
Mon Feb 17 23:00:00 UTC 2025
You need to first build the date object by parsing the field, using the .toDate method, like so:
#set ($removeDateObj= $__dateTool.toDate(“EEE, dd MMM yyyy HH:mm:ss zzz”,$removeDate))
Then, you can use the .format method to set a new variable with the desired fields:
#set ($removeDateObjFormatted= $__dateTool.format(“MM/dd/yyyy”, $removeDateObj))
And finally, you can reference those variables in the body of the email template.
1 Like
sahincelik
(Sahin Celik)
February 14, 2025, 8:26am
3
Hi Maria,
I just re-tested by configuring exactly you mentioned. However I still get the same result.
#foreach ( $type in ${requestedObjectDetailsByType.keySet()} )#foreach ( $detail in ${requestedObjectDetailsByType.get($type)} )
${detail.name} #if ($detail.removeDate)
#set ($removeDateObj = $__dateTool.toDate(“EEE, dd MMM yyyy HH:mm:ss zzz”, $detail.removeDate))
#set ($removeDateObjFormatted = $__dateTool.format(“MM/dd/yyyy”, $removeDateObj)) De rol wordt ingetrokken op ${removeDateObjFormatted} #end
#end
nikhleshsdg
(Nikhlesh Sheoran)
February 14, 2025, 12:56pm
4
Hi Sahin,
You can refer this doc to format the date in Email template.
DateTool (VelocityTools 2.0 Documentation)
Thanks.
Sahin,
Also, make sure that you are using the straight quotes (" ") and not the curly quotes (“ ”) when you instantiate strings inside the methods.
sahincelik
(Sahin Celik)
February 18, 2025, 2:59pm
6
Thanks both, please see the email template below. This is designed just like you mentioned and there is no quotes issue, yet I can’t change the date format. Any idea what is missing?
Dear ${user.name},
You've requested access for the following identities:
#foreach ( $requestDetail in $requestDetails )
${requestDetail.identityName}:
#set ($successDetails = $requestDetail.getSuccessDetails())
#if ($successDetails && $successDetails.size() > 0)
The following item(s) were requested successfully:
#foreach ( $typeEntry in $objectTypeToPrettyPrint.entrySet() )
#set ($type = $typeEntry.getKey())
#set ($prettyType = $typeEntry.getValue())
#set ($objectDetails = ${successDetails.get($type)})
#if ($objectDetails.size() > 0)
<li>$prettyType:
<ul>
#foreach ($requestedObjectDetail in $objectDetails)
<li>${requestedObjectDetail.objectName}
#if ($requestedObjectDetail.removeDate)
(Access Sunset Date:
$spTools.formatOffsetDateTimeForEmail($requestedObjectDetail.removeDate)
$spTools.formatDate($requestedObjectDetail.removeDate,"MM/dd/yyyy"))
#end
</li>
#end
</ul>
</li>
#end
#end
#end
#set ($exclusionDetails = $requestDetail.getExclusionDetails())
#if ($exclusionDetails && $exclusionDetails.size() > 0)
Your request for the following item(s) failed :
#foreach ( $typeEntry in $objectTypeToPrettyPrint.entrySet() )
#set ($type = $typeEntry.getKey())
#set ($prettyType = $typeEntry.getValue())
#set ($objectDetails = ${exclusionDetails.get($type)})
#if ($objectDetails.size() > 0)
<li>$prettyType:
<ul>
#foreach ($requestedObjectDetail in $objectDetails)
<li>${requestedObjectDetail.objectName}
#if ($requestedObjectDetail.exclusionReason)
($requestedObjectDetail.exclusionReason)
#end
</li>
#end
</ul>
</li>
#end
#end
#end
#end
Thanks, The ${PRODUCT_NAME} Team
#set ($removeDateObj= $__dateTool.toDate(“EEE, dd MMM yyyy HH:mm:ss zzz”, $removeDate))
#set ($removeDateObjFormatted= $__dateTool.format(“MM/dd/yyyy”, $removeDateObj))