Email template date format

Hello all,

I’m trying to format the date in the “Access Request” email templates. Some of these email templates include the expiration date (from “removeDate”) as a string argument (according to the documentation: Access Request Reviewer Email Template v1).

Since this is a version 1 template, I tried using the spTools.formatDate() function to define what the date should look like in the email, but this doesn’t seem to work. According to the documentation (Available Email Templates - SailPoint Identity Services) I should be able to use spTools.formatDate($removeDate,“dd-MM -yyyy”) to convert the date from “Monday March 4th 11:00:00 UTC 2024” to 04/03/2024. However, the result is sobering as nothing is returned (empty).
It seems quite complicated to define the correct date and time format for your region, especially with version 1 email templates.
Has anyone managed to solve this issue?

Thanks in advance!

This was the same topic but it seems to be never resolved:
https://developer.sailpoint.com/discuss/t/date-formatting-of-string-dates-in-email-templates/

Check this post

You can ignore the .add part

1 Like

Hi,
thanks for the link. I did read this article already. It is good to know how to get the current date from the own time zone. But this does not help for the Email Templates witch does use a variable like the $removeDate. I tried to change the script but the result is the same.

Thanks in advance!

#set($spToolsClass = $spTools.getClass())
#set($calendarClass = $spToolsClass.forName("java.util.Calendar"))
#set($calendarInstance = $calendarClass.getInstance())
$calendarInstance.setTime($certification.expiration)
#set($formattedDate = $spTools.formatDate($calendarInstance.getTime(), "MM/dd/yyyy HH:mm"))

You can try something like this. Replace certification.expiration with removeDate

Thanks Nithesh for the quick reply.
Unfortunately, this doesn’t work either. We do not receive any email now. I tried a couple of combination and nothing did work.

we do use this:

#foreach ( $type in ${requestedObjectDetailsByType.keySet()} ) $type: #foreach ( $detail in ${requestedObjectDetailsByType.get($type)} )
${detail.name} #if($detail.removeDate) (remove date: $detail.removeDate)#end#endxend

result:
remove date: Tue Mar 12 23:00:00 UTC 2024

I am grateful for any further ideas.
Thanks in advanced.