SOLVED

Velocity Token - Account based CO

Go to solution
Travis_Schwartz
Level 3

Velocity Token - Account based CO

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. 

 

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity Token - Account based CO

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

 

View solution in original post

18 REPLIES 18
SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity Token - Account based CO

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?

 

syntax_vtl.png

Travis_Schwartz
Level 3

Re: Velocity Token - Account based CO

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 - Community Moderator

Re: Velocity Token - Account based CO

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?

Travis_Schwartz
Level 3

Re: Velocity Token - Account based CO

I think that is the problem. The code I used was based on something I found on the community. How would I ensure that it is looking at the description field other than checking it in the token builder?

Travis_Schwartz
Level 3

Re: Velocity Token - Account based CO

It's been a couple days and I'm hoping this will get some action on this page. Tagging @SanfordWhiteman if that will help.

 

If I simplify it, perhaps that would give me the immediate solution that I could then incorporate into the other products. 

 

Let's start with the Visa card. I need to create a campaign that is triggered by someone having a payment due in 10 days for their ARROWHEAD VISA.

 

The products live in the account section of our custom objects.

 

We would need a velocity token to display the due date for the corresponding product.

the name of the product (ARROWHEAD VISA) lives in the $account_cList.description field (string), and the payment due date I need lives in the $account_cList.upcomingPaymentDate field (date).


When I export all of the description values for $account_cList.description, the one I need for this project is  {description=ARROWHEAD VISA}. I can export the payment date field as well, and the one I would use (for this individual) is  {upcomingPaymentDate=2020-04-15}

Based on my digging around, I assume I need to do:

 

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

 

But it is not returning results. I'm obviously going wrong somewhere. any assistance would be greatly appreciated.

Tags (2)
Travis_Schwartz
Level 3

Re: Velocity Token - Account based CO

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.

SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity Token - Account based CO

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

 

View solution in original post

Travis_Schwartz
Level 3

Re: Velocity Token - Account based CO

Thanks, 

It is definitely a learning curve. I look at other examples, feel I understand what they are trying to accomplish, but sometimes the nuances are a little trick.

That is exactly what I am trying to accomplish.

It is still displaying as blank when I preview it or send a test email using a person who has those values in their account CO.


I have double checked to make sure that both the description and upcomingpaymentdate selections are checked off. Is there anything else that I would need to include to get the value to display?

SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity Token - Account based CO

There's no output line in the code, that's finding the value and setting $dueDate.

 

If you want to output $dueDate, then you need a line

 

${dueDate}