Selecting a particular Custom object to display in Velocity Token for emails

LCENTENO
Level 3

Re: Selecting a particular Custom object to display in Velocity Token for emails

Hi Sandford, 
I hope I got this correct. So, I applied this code below:

#set( $interestingProductCodes = ["NEW AUTO CE12","SECURED OTHER GOODS CE12","REC VEHICLE OE","SECURED OTHER GOODS OE","PCU USED VEHICLE","PCU USED VEHICLE JR MEETING","PCU NEW VEHICLE","NEW AUTO ALTERN IL","USED AUTO ALTERN IL","USED AUTO ALTERN WI","USED AUTO OE","NEW AUTO OE","MOTORCYCLE CE12","REC VEHICLE CE12"] )

#foreach( $account in $cCUAccount_cList )
#if( $interestingProductCodes.contains($account.productCode) )
${account.getCurrentPayment}
#end
#end
#set($currentPayment = $number.currency(${cCUAccount_cList.get(0).currentPayment}))
#if(!$currentPayment)
  #set($currentPayment = "$0.00")
#end
${currentPayment}

It looks like it is displaying the payment information when I previewed by a list:

LCENTENO_0-1683578779915.png

That being said, can you confirm if I am on the right track?

Along with the current payment, we also want to grab the NextDueDate that corresponds with that CO that displays the $850.47.

Is there anything that can be done with the above code to ensure that it grabs the information in the NextDueDate field? Thanks in advance.

Lucas


SanfordWhiteman
Level 10 - Community Moderator

Re: Selecting a particular Custom object to display in Velocity Token for emails

Sorry, this is not at all correct.

 

Seems like you still don’t understand what List.get(0) (and its synonym, List[0]) is doing. That’s getting the first item in the list, with the list sorted in what you should consider arbitrary order to start with. Using this method outside of, and in addition to, the loop makes no sense.

 

The only scenario in which grabbing List.get(0)makes sense is if (a) you are sure of the sort order because you sorted it yourself, and (b) the first item in the list has a specific business meaning, while all the other items do not.

 

And you still haven’t shown the raw output of the list as requested above.

LCENTENO
Level 3

Re: Selecting a particular Custom object to display in Velocity Token for emails

Hi Sandford,
So, would I need to eliminate the all the code after line 7 altogether (below), or is there an adjustment that can be made to the already current code?
I also noticed that in the scripting there were these two items, that being ContractDate and Created At. 

LCENTENO_0-1683647728940.png

We are trying to determine a more or less "sweet spot" timeframe to pull the correct record. So, would the two items mentioned above be a factor that needs to be applied to the code below. For example, if we wanted to pull a record with a contract date that was within the last 20 days, or a Created At time of the last 20 days. How would we apply that into the code below?

#set( $interestingProductCodes = ["NEW AUTO CE12","SECURED OTHER GOODS CE12","REC VEHICLE OE","SECURED OTHER GOODS OE","PCU USED VEHICLE","PCU USED VEHICLE JR MEETING","PCU NEW VEHICLE","NEW AUTO ALTERN IL","USED AUTO ALTERN IL","USED AUTO ALTERN WI","USED AUTO OE","NEW AUTO OE","MOTORCYCLE CE12","REC VEHICLE CE12"] )

#foreach( $account in $cCUAccount_cList )
#if( $interestingProductCodes.contains($account.productCode) )
${account.getCurrentPayment}
#end
#end
#set($currentPayment = $number.currency(${cCUAccount_cList.get(0).currentPayment}))
#if(!$currentPayment)
  #set($currentPayment = "$0.00")
#end
${currentPayment}

 As far as the raw output of the list, I am not sure what you are referring to. Thanks again for your continued support.