How to get a token script to display information from Opportunity Object? | Community
Skip to main content
New Participant
September 7, 2018
Solved

How to get a token script to display information from Opportunity Object?

  • September 7, 2018
  • 1 reply
  • 7161 views

Hi all,

I'm trying to create custom token scripts based on items on the opportunity object. However, when I follow the directions here, Create an Email Script Token - Marketo Docs - Product Documentation,​ it doesn't render.

For example, I create a custom token. I call it my.ExampleTokenA. I need it to show the value for Example Opportunity Item A from the Opportunity Object.

When I edit the token, I go to the Opportunity object list, and pick Example Opportunity Item A from the list, and drag it over. So now in my script editor, I see ${OpportunityList.get(0).Example_Opportunity_Item_A}.

However, when I go to test my token, instead of seeing that value, I see ${OpportunityList.get(0).Example_Opportunity_Item_A}. What do I need to do to get it to display the value? No additional formatting is needed; I just need it to display what's there.

Thanks!

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

Ok, I did more digging on the SFDC side and the stuff is going over okay, there's just not data in those particular fields yet.

So next question - if a field is null, how can I get it to display "---", instead of displaying the script?


Ok, I did more digging on the SFDC side and the stuff is going over okay, there's just not data in those particular fields yet.

Ah, yes, so not a Velocity thing.

So next question - if a field is null, how can I get it to display "---", instead of displaying the script?

$display.alt($OpportunityList[0].Example_Opportunity_Item_A, "---")

1 reply

SanfordWhiteman
New Participant
September 7, 2018

You must test Velocity tokens using preview-by-list with a static list or via a real email (not sample).

Also note your code here is using the first Oppty in the list. That may not be practical.

New Participant
September 10, 2018

I set the test up using preview-by-list, but I'm still getting the token script spit back to me (though, oddly, a few don't show any value at all). Any ideas as to what might be going on here?

As far as I know, the first in the list is acceptable at this point; I think the main concern is getting a value to show up instead of velocity script right now.

Thanks!

SanfordWhiteman
New Participant
September 10, 2018

I assume you've made sure that Example_Opportunity_Item_A ​is still checked in the list on the right-hand-side? (Sometimes they get unchecked unexpectedly.)

The way to start lower-level debugging is to include

$display.list( $OpportunityList, "\u000a" )

in the token and look in the Text version of the email. (Using the Text instead of HTML version ensures that no output is ever parsed and swallowed up by your browser.)

Also, can you show some screenshots establishing that the people in your test static list have at least one Opportunity?