AnsweredAssumed Answered

Filtering Custom Object by Date in Velocity

Question asked by Samantha Cossum on Sep 16, 2019
Latest reply on Sep 16, 2019 by Samantha Cossum

Hi all,

I have a program running that looks at training records for our clients (which we store in COs) and will send an alert to our vendor to delivery something if the date of the training is within 14 days. I have an email script set up to pull the date of the training in to the alert to the vendor and I had originally set it up to sort by training IDs. While that is working for most I am running into the occasionally issue where the date it pulls in is not the upcoming one. I can't filter these by that date field because not every training is currently scheduled. 

 

My desire is to try and filter by the date being in the next 14 days. I've looked though the community and tried to apply some things but I'm struggling to get anything to work. Below is the script I already have running:

 

#set( $defaultTimeZone = $date.getTimeZone().getTimeZone("America/Toronto") )
#set( $defaultLocale = $date.getLocale() )
#set( $calNow = $date.getCalendar() )
#set( $ret = $calNow.setTimeZone($defaultTimeZone) )
#set( $calConst = $field.in($calNow) )
#set( $ISO8601 = "yyyy-MM-dd'T'HH:mm:ss" )
#set( $ISO8601DateOnly = "yyyy-MM-dd" )
#foreach( $event in $sorter.sort($trainingRecord_cList,"trainingID:asc") )
#if( $event.trainingStatus.equalsIgnoreCase("confirmed") )
#set( $latestEventDate = $event.trainingScheduledStartDate)
#set($origDate = $convert.parseDate($latestEventDate,$ISO8601DateOnly,$defaultLocale,$defaultTimeZone))
#set($formattedDate = $date.format('full_date',$origDate,$defaultLocale,$defaultTimeZone))
$formattedDate#break
#end   
#end

 

So preferable, this would pull in the start date of the training if it is confirmed and the started date is within 14 days.

 

Any suggestions or direction would be much appreciated! Thanks! 

Outcomes