Question
Sorting Opportunities for opportunitylist which has several opportunities
Please forgive my lack of knowledge as I have just started coding the script.
I'm trying to create the script token which retrieves the date "Field93__c" in $OpportunityList and show the date which is 6 month after the date of "Field93__c".
But the below script can work for the lead which has the only one opportunity. And it does not work correctly for the lead which has several opportunities.
How should I correct?
#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( $JapanDate = "yyyy年MM月dd日")
#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( $sortedUpdated = $sorter.sort($OpportunityList,"Field93__c"))
#if($sortedUpdated[0].Field93__c && !$sortedUpdated[0].Field93__c.isEmpty())
#set( $inputDate = $convert.toCalendar(
$convert.parseDate(
$sortedUpdated[0].Field93__c,
$ISO8601DateOnly,
$defaultLocale,
$defaultTimeZone
)
))
$inputDate.add($calConst.MONTH,6)
${date.format(
$JapanDate,
$inputDate,
$defaultLocale,
$defaultTimeZone
)}
#else
お問い合わせにてご回答可能
#end