Formatting date in the email subject line for Workflows

I am looking to format the date for use in the email subject line of workflows. have used Velocity for the email body and it works fine but the same isnt working for the subject line

**Subject line** - End Date advice for ${name} on ${Need to add the formatted date here}


**Email body**
<p>Termination advise that ${name}'s last day was #set($dateObj = $__dateTool.toDate("yyyy-MM-dd'T'HH:mm:ss", ${expirydate}))
#set ($formattedDate = $__dateTool.format("dd/MM/yyyy", $dateObj)), $formattedDate


**Templating Context** {"expirydate.$":"$.getIdentity.attributes.contractEndDate","name.$":"$.getIdentity2.name"}

The dates I am getting are in this format yyyy-mm-ddT00:00:00 where I need them to be in dd/mm/yyyy

Hi @KirtiSikarwar ,

Not sure if its already resolved. The same set code should work fine for Subject line as well.

**Subject line** - End Date advice for ${name} on #set($dateObj = $__dateTool.toDate("yyyy-MM-dd'T'HH:mm:ss", ${expirydate}))
#set ($formattedDate = $__dateTool.format("dd/MM/yyyy", $dateObj)), $formattedDate

You can give it a try. It worked for me.

Hi @shaileeM it worked for me. When I do the test run its giving me the dates but when I enable it and for any user that is getting terminated it giving me $formattedDate

Hi @KirtiSikarwar , can you verify that the contractEndDate of the target user has some value. If its empty, $formattedDate will not be calculated also and it will appear as $formattedDate

You are right, they put in the terminated date instead of enddate

1 Like