SOLVED

What is wrong with my token?

Go to solution
Travis_Schwartz
Level 3

What is wrong with my token?

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.

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: What is wrong with my token?

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?

View solution in original post

16 REPLIES 16
SanfordWhiteman
Level 10 - Community Moderator

Re: What is wrong with my token?

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.

Travis_Schwartz
Level 3

Re: What is wrong with my token?

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.

SanfordWhiteman
Level 10 - Community Moderator

Re: What is wrong with my token?

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?

View solution in original post

Travis_Schwartz
Level 3

Re: What is wrong with my token?

We have custom list object for people who have had a card returned and it that List ID is called Returned Card Notice

SanfordWhiteman
Level 10 - Community Moderator

Re: What is wrong with my token?

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.

Travis_Schwartz
Level 3

Re: What is wrong with my token?

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. 

Travis_Schwartz
Level 3

Re: What is wrong with my token?

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.

SanfordWhiteman
Level 10 - Community Moderator

Re: What is wrong with my token?

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.

Travis_Schwartz
Level 3

Re: What is wrong with my token?

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?