Cant get velocity token to work - I think it's a date parsing issue
So I have a custom list (account_cList).
I want it to check if ${account_cList.get(0).productType} has one of the qualifying (integer) values:
1001, 1002, 1003, 1004, 1009, 1010, 1011, 1012, 1027, 1028, 1200, 1201, 1202, 1203, 1204, 1205, 1210, 1211, 1213, 1214, 1215
Next, I want to look at ${account_cList.get(0).openDate} (date) and see if that date is in the last 7 days
and if it has a value there, I want to take ${account_cList.get(0).autoMake} and ${account_cList.get(0).autoModel} and convert them to title case (they are all caps by default). If there is a value in both or either, i want it to just show that. if there is a value in neither of those fields, I want it to default to "new ride".
I am only able to get it to show the default (new ride), even when there are qualifying people who should have the make and model display a value. Below is the script I used.
#set( $defaultTimeZone = $date.getTimeZone().getTimeZone("America/Los_Angeles") )
#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($validProductTypes = [1001, 1002, 1003, 1004, 1009, 1010, 1011, 1012, 1027, 1028, 1200, 1201, 1202, 1203, 1204, 1205, 1210, 1211, 1212, 1213, 1214, 1215])
## Check if productType is valid and openDate is within the last 7 days
#if($validProductTypes.contains(${account_cList.get(0).productType}))
#set($currentDate = $dateTool.now())
#set($openDate = $dateTool.parse('yyyy-MM-dd', ${account_cList.get(0).openDate}))
#set($dateDiffMillis = $dateTool.diff($currentDate, $openDate, 'days'))
#if($dateDiffMillis >= 0 && $dateDiffMillis <= 7)
## Format autoMake and autoModel with capitalized first letters
#set($make = ${account_cList.get(0).autoMake})
#set($model = ${account_cList.get(0).autoModel})
#if($string.isNotBlank($make))
#set($make = $string.capitalize($make.toLowerCase()))
#else
#set($make = "")
#end
#if($string.isNotBlank($model))
#set($model = $string.capitalize($model.toLowerCase()))
#else
#set($model = "")
#end
Open Date (Formatted): $dateTool.format('yyyy-MM-dd', ${account_cList.get(0).openDate})
#if($string.isNotBlank($make) || $string.isNotBlank($model))
#if($string.isNotBlank($make))
Make: $make
#end
#if($string.isNotBlank($model))
Model: $model
#end
#else
new ride
#end
#else
new ride
#end
#else
new ride
#end