Velocity Token - Account based CO | Community
Skip to main content
Travis_Schwartz
Level 4
April 22, 2020
Solved

Velocity Token - Account based CO

  • April 22, 2020
  • 1 reply
  • 5740 views

I've been searching all over the community trying to find a solution for this likely easy issue. I feel I had a similar project previously but I can't find it and I've been searching for too long.
I need to create a velocity script that identifies a payment is coming due. I want to identify what the payment is for (credit card, used car, new car, mortgage, etc.) that information is all under the description (string) field in the Marketo custom object under accounts. I would also need to pull in the corresponding due date (upcomingPaymentDate - Date) field

 

This is what I've done so far and it keeps returning the "no matching list found." message when I use records that it should identify as belonging to this script.

 

#foreach( $list in $account_cList )#if( $list.listID.equals("description") )
#set( $targetList = $list )#break
#end
#end
${display.alt($targetList.description, "no matching list found.")}

 

 

Something else I would need to add would be the date the payment would be due. I would love to do it all in the same script, but if I need to do a separate token, I would appreciate some guidance on how to set that up so that they would be linked to make sure the payment due date that the system was referring to was the same item in the description.

 

The end result, I would need to display something similar to:

 

Account Type: $description

Payment Due Date: $upcomingPaymentDate

 

Thank you for your assistance. 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

When I check description and the upcomingPaymentDate on a particular record that I know has this product I get:

 

{description=ARROWHEAD VISA, upcomingPaymentDate=2020-04-15},

 

but results are still null or empty when I use my coding.


You seem to be throwin' stuff at the wall here:

 

#set( $dueDate = [] ) #foreach( $list in $account_cList ) #if( $account_cList.description.equals("ARROWHEAD VISA") ) #set( $dueDate = $account_cList.upcomingPaymentDate ) #end #end

 

You're setting $dueDate to an empty List ([]). Then you're looping over $account_cList but never checking the individual items (rather bizarrely named $list) in the list!

 

This wouldn't even make sense in pseudo-code, in other words. Try to read your logic out loud as you look at the code, you're not really implementing anything useful here.

 

It sounds like your intended logic is:

  • loop over the list of accounts
  • find the first account that has its description property equal to "ARROWHEAD VISA"
    • set a variable $dueDate to the upcomingPaymentDate property of that account
    • exit from the loop

There's nothing wrong (and everything right) with writing out your business logic in this plain(ish)-English way. It takes years of coding before you can implement something straight away without sketching it out.

 

For the logic above and your known dataset, the code would be

 

#foreach( $account in $account_cList ) #if( $account.description.equals("ARROWHEAD VISA") ) #set( $dueDate = $account.upcomingPaymentDate ) #break #end #end

 

1 reply

SanfordWhiteman
Level 10
April 22, 2020

You have to show more of the raw object data to see why the iterate-and-filter technique isn't working. 

 

Also, can you use the syntax highlighter for your code?

 

Travis_Schwartz
Level 4
April 22, 2020

What additional raw object data is needed? Does this refer to all of the possible items that could be under the description tag? 

here is the code in the syntax highlighter:

#foreach( $list in $account_cList )#if( $list.listID.equals("description") ) #set( $targetList = $list )#break #end #end ${display.alt($targetList.description, "no matching list found.")}

 

I appreciate the help.

SanfordWhiteman
Level 10
April 23, 2020

There's nothing syntactically wrong with your code.

 

But that doesn't mean the data is there, and there's nothing to prove that it is. Can you prove that the property description is a (non-null) property of the object $targetList?