SOLVED

Re: Commas In-Between Outputs from Single Field?

Go to solution
nhabischWings
Level 5

Re: Commas In-Between Outputs from Single Field?

Got it makes sense - I'm close but not sure what's incorrect with my output:

## iterate Customer Profiles, looking for those with Membership Opening yesterday
#foreach( $item in $customerProfilesList )
#set( $membershipOpeningDate = $convert.parseDate(
    $item.membershipDate,
    $ISO8601DateOnly, 
    $defaultLocale, 
    $defaultTimeZone 
) )
##Sets difference from Membership Opening Date between 1 and 7 days
#set( $minDiff = -7 )
#set( $maxDiff = -1 )
#set( $diffDays = $date.difference($calNow,$membershipOpeningDate).getDays().intValue() )
#if( ( $diffDays.compareTo($minDiff).equals(1) || $diffDays.equals($minDiff) ) 
  && ( $diffDays.compareTo($maxDiff).equals(-1) || $diffDays.equals($maxDiff) ) && $item.membershipStatus.equals("Member") )
#set( $fullNames = [] )
#set( $void = $fullNames.add($item.fullName) )
${display.list($fullNames)}
#else
#end
#end

Theoretically I'd think the above should work since everything is within the #foreach loop and the list is set from within the #if conditional - but the display.list output displays the correct values, but not list formatted.


I've also tried putting the output outside of the loop, thinking that the #set within the conditional would set the correct values, but that only outputs 1 of the 2 correct values.

SanfordWhiteman
Level 10 - Community Moderator

Re: Commas In-Between Outputs from Single Field?

Inside the loop, you’re continually setting $fullNames to an empty list and then populating it with a single item.

nhabischWings
Level 5

Re: Commas In-Between Outputs from Single Field?

Thank you! Got it to work with: 

##Standard Velocity Date/Time Fields
#set( $defaultTimeZone = $date.getTimeZone().getTimeZone("America/Chicago") )
#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 blank array for future values
#set( $fullNames = [] )
## iterate Customer Profiles, looking for those with Membership Opening yesterday
#foreach( $item in $customerProfilesList )
#set( $membershipOpeningDate = $convert.parseDate(
    $item.membershipDate,
    $ISO8601DateOnly, 
    $defaultLocale, 
    $defaultTimeZone 
) )
##Sets difference from Membership Opening Date between 1 and 7 days
#set( $minDiff = -7 )
#set( $maxDiff = -1 )
#set( $diffDays = $date.difference($calNow,$membershipOpeningDate).getDays().intValue() )
#if( ( $diffDays.compareTo($minDiff).equals(1) || $diffDays.equals($minDiff) ) 
  && ( $diffDays.compareTo($maxDiff).equals(-1) || $diffDays.equals($maxDiff) ) && $item.membershipStatus.equals("Member") )
#set( $void = $fullNames.add($item.fullName) )
#else
#end
#end
${display.list($fullNames)}