So I'm trying to script a token based on a custom object... most importantly I want it to display text field 2 if someone has that custom object on their record.
I see this option in the coding, but am not sure how to tell Marketo which list to reference to display the text2 field.
${customList_cList.get(0).text2}
I think this should be relatively simple, but am not having any luck with it so I figured I would reach out.
Thanks in advance.
Solved! Go to Solution.
That code is outputting the text2 property of the 0th (i.e. first) item in the ArrayList of customList objects, in what you should consider an arbitrary sort order.
What is the “correct” customList object?
Please highlight your code using the Advanced Editor’s syntax highlighter (you can choose Java as the language as it’s closest to Velocity). Then we’ll continue.
This is new to me, so let me know if I get it right.
${customList_cList.get(0).text2}
I need to know how to identify which list Marketo is referencing to get the correct text2 content to display.
Thanks.
That code is outputting the text2 property of the 0th (i.e. first) item in the ArrayList of customList objects, in what you should consider an arbitrary sort order.
What is the “correct” customList object?
We have custom list object for people who have had a card returned and it that List ID is called Returned Card Notice
Please output the entire $customList_cList so I can see the Velocity property names for those fields.
Make sure the fields are checked off in the tree on the right-hand side of Script Editor.
I'm not sure I know how to do that. Is there some documentation you could point me to? I'm still very much a Marketo rookie and am noticing we are missing out on things by not utilizing scripting tokens, but I'm at the early stages of investigating what it would take to implement.
I truly appreciate your help and patience.
Okay. I think I figured out.
Please let me know if this sounds right:
${customList_cList.get(2).text2}
and the (2) is referencing the specific Custom Object list and displaying the text 2 field.
Thanks for your help Sanford.
No, arbitrarily choosing the 3rd object in the list, a list that should not be considered to be in any particular business order by default, is certainly not the solution.
I didn't arbitrarily choose the 3rd object.
I went to admin - Database management - Marketo Custom Objects - used by and only one of them (the card return object) uses the Text2 field. and that one is the 3rd object on that list with a ListID. so that is why I selected the 3rd object and am seeing the results that line up with that list object.
Does this past muster or is there something else I should check it against or another way to see which list it should reference?
The order of the list of records attached to a given lead is in no way visible in Admin. So I can't imagine what you're referring to here.
Every lead can have zero or more records of the same type of CO, and all those records will have all of the fields available on that CO. The fields may be empty for some of the records, and the records may be added in any order. The 3rd record in a list has no inherent meaning.
Can you point me to where I would be able to see the list of entire $customerList_cLost you wanted me to output so I can get the Velocity property names for the fields?
Just output the full
${customList_cList}
in a Velocity token, and preview the email by lead or list.
[{listID=eStateMent List, text2=null, listName=null}, {listID=Card Expiration Notice, text2=null, listName=null}, {listID=Returned Card Notice, text2=6586, listName=null}, {listID=Mobile Confirmation, text2=VISA Debit Card, listName=null}]
OK, you want to seek your target record by iterating over the CO list until you find the first match. Then exit (#break) to save processing overhead.
#foreach( $list in $customList_cList )
#if( $list.listID.equals("Returned Card Notice") )
#set( $targetList = $list )
#break
#end
#end
${display.alt($targetList.text2,"No matching list found.")}
Note if you add additional records later that also match "Returned Card Notice" (no technical reason why that couldn't happen) you'll need to figure out which one to use: the first match by date, last match by date, or something else.
Thanks for persevering through this with me, Sanford.
How it works on our end is records are tagged with the card return notice CO, and when that is resolved, it is synced from our server and cleared from their record. in this case would I still need to do the match by date? or would just anyone who had that CO be added. Ideally this will be an automated process that just happens as members qualify to have the CO added to their record.
You don't need to worry about match by date, then. Just use the code from my last post.