Ok, I am having a little trouble grasping what you're saying (again first time in velocity and Java). So for the code below:
#set( $interestingProductCodes = ["PRODUCT 1","PRODUCT 2","PRODUCT 3"] )
#foreach( $account in $cCUAccount_cList )
#if( $interestingProductCodes.contains($account.productCode) )
${cCUAccount_cList.get(0).currentPayment}
#end
#end
Are you saying that line 4 in the code (${cCUAccount_cList.get(0).currentPayment}) should be moved up to line 1? As far as the properties of $account, can you clarify? I assumed that I was doing that in line 2 of the code. Thanks.
Best,
Lucas
Are you saying that line 4 in the code (${cCUAccount_cList.get(0).currentPayment}) should be moved up to line 1?
No, I’m saying that line shouldn’t exist anywhere! There’s no reason, inside a #foreach loop, to ever be directly referencing the 0th (first) item in the list.
Velocity sets the loop variable to the value of each item of the list, in turn.
This code:
#set( $mylist = [1,2,3,4] )
#foreach( $myloopvariablename in $mylist )
loop var value is ${myloopvariablename}
#end
Will output:
loop var value is 1
loop var value is 2
loop var value is 3
loop var value is 4
It’s the same idea in any language that has a for/foreach concept.
Did you read my post on loops in Velocity?
I have but again, I am a beginner in Velocity and Java so it's a little difficult to wrap my head around it. I have an understanding of the code below, but what I want to know is how do I get the "Current Payment" to display based on the criteria of this code. I do not see anything in the code that references the Current Payment.
#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) )
#end
#end
The display name is CurrentPayment
API Name is currentPayment
Hi @SanfordWhiteman , so I have been playing with the different coding examples you provided and I am still unable to get the token to show the value in the Current Payment field. I have a question, regarding the interesting product code #set you placed (line 1).
#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) )
$lead.Lead_CurrentPayment
#end
#end
How does Marketo recognize this if the field and Custom object is labeled "Product". Does adding this effect the ability to grab the right info? Secondly after the line with the "if" code, is the next line below the correct action line to get the token to display the Current Payment based on the criteria?
Thanks in advance for your continued help.
Best,
Lucas
$interestingProductCodes is just a variable name, a mere identifier local to your script for storing the products you want to search for in Account CO records’ productCode field. Additionally, if it helps, when you loop through a CO list of records, in each iteration, a particular CO record is picked and referenced in the loop body at a time (I.e., it processes records in the order they are stored one by one) until either a break statement is encountered in the loop body or it is done iterating through all the records in the CO. Also, is Lead_CurrentPayment a custom field on the person object field and not a custom field on the Account CO?
How does Marketo recognize this if the field and Custom object is labeled "Product".
Sorry, don’t understand the question. You said the Custom Object list is:
$cCUAccount_cList
And you said the Custom Object has property names like:
productName
You’d only know these names if you dragged first dragged the object onto the Script Editor “canvas” (left hand side) from the tree (right hand side).
Hi Sandford,
Basically, every time a member opens a new product account it's housed under the CO category of CCU Account. To answer your question, yes, the CO is named CCU Account with these display names.
I just want to create two separate custom tokens to pull CurrentPayment and NextDueDate display information, based on the "Product" display name categories, since there can be several different CCU Account COs per member, hence the list of 14 products mentioned in previous posts.
Is there a "one-stop-shop' code that can pull this info and be applied to both of the custom tokens for "currentpayment" and "nextduedate"?
Hopefully this makes more sense.
Best,
Lucas
You don’t get the Velocity name for an object or property (we’re talking about Velocity names, not REST API names) from the Admin section.
You get it by dragging it onto the Script Editor canvas, also ensuring that it’s checked off on the right-hand-side.
Agreed! To Sandy's point you should be pulling attributes you want to use in the velocity script from the object tree on the right of the email script editor (snapshot below):
Unless the referenced attributes aren't check-marked in the tree, they won't be available to the email script token during the runtime, and Marketo won't be able to reference their value in the code.
I've added a snippet below for your reference as well:
#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.currentpayment}
${account.nextduedate}
#end
#end
This code snippet will display "currentpayment" and "nextduedate" for all the CO records with productCode set to one of the interesting product code values for a person. You may break this email script token into 2 tokens if you wish to display "currentpayment" and "nextduedate" at different places and not together. Additionally, if you only want to print the most recently updated matching record, then you'd have to sort the CO. Let us know if you need help in the code for the sort.
Hi Darshil,
This is starting to make more sense. I checked off the items on the right in the script editor then applied the token code you provided into the email. When I previewed using a specific account that only had one loan, it is still not showing the currentpayment amount.
See screenshot below:
Since this is going to be sent to members who open a new loan. We will definitely want to ensure that Marketo pulls the correct CO record. Any help as far as adjusting the code you provided to pull the most recent loan account only, and addressing the issue above is greatly appreciated. Also, I appreciate the continued support of both yourself and Sandford.
Best,
Lucas