HI Sandy
Thank you for your comment.
Could you check the below?
-- Purpose
To send the marketing campaign promotion to the customers who terminates the contract
e.g.
The customer A : terminate the contract Jan. 1st
Send the mail B on Feb 1st
In the mail B, I want to include the following statement
The special promotion will ends on Mar 1st
(→ This date should be defined as 2 months after the termination date.)
-- Script Token
#set( $defaultTimeZone = $date.getTimeZone().getTimeZone("Asia/Tokyo") )
#set( $defaultLocale = $date.getLocale() )
#set( $sortedList = $sorter.sort($OpportunityList,"LastActivityDate"))
→ {LastActivityDate=2023-01-21, MarketoCreatedAt=2022-02-08 23:14:56, LastStageChangeDate=2023-01-11 00:09:25}
I understand $sortedList object is different from $date.getCalendar() and should handle in a different way.
But I do not know how I should handle to add 2 months to LastActivityDate.
Please advise.
Could you try the below script?
#set( $defaultTimeZone = $date.getTimeZone().getTimeZone("Asia/Tokyo") )
#set( $defaultLocale = $date.getLocale() )
#set( $calNow = $date.getCalendar() )
#set( $ret = $calNow.setTimeZone($defaultTimeZone) )
#set( $calConst = $field.in($calNow) )
#set( $ISO8601DateOnly = "yyyy-MM-dd" )
#set( $ISO8601DateTime = "yyyy-MM-dd'T'HH:mm:ss" )
#set( $ISO8601DateTimeWithSpace = "yyyy-MM-dd HH:mm:ss" )
#set( $ISO8601DateTimeWithMillisUTC = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" )
#set( $ISO8601DateTimeWithMillisTZ = "yyyy-MM-dd'T'HH:mm:ss.SSSZ" )
#set( $sortedList = $sorter.sort($OpportunityList,"LastActivityDate"))
##sort the list in ascending (asc)/descending (desc) order as required
#set( $dateObj = $convert.toCalendar(
$convert.parseDate(
$sortedList.get(0).LastActivityDate,
$ISO8601DateOnly,
$defaultLocale,
$defaultTimeZone
)
) )
$dateObj.add($calConst.MONTH, 2)
${date.format(
$ISO8601DateOnly,
$dateObj,
$defaultLocale,
$defaultTimeZone
)}