Fetch Opportunity owner in Email Script token | Community
Skip to main content
New Participant
August 4, 2023
Question

Fetch Opportunity owner in Email Script token

  • August 4, 2023
  • 1 reply
  • 741 views

Hi there,

I am trying to fetch the opportunity owner from opportunities tied to a person record in Marketo Database. I am trying to use Velocity but it is not working for me. Can someone let me know what am I doing wrong?

#set( $opportunity = $lead.Opportunity ) #if( $opportunity && $opportunity.OpportunityOwnerName && $opportunity.OpportunityOwnerName != "") Opportunity Owner Name: $opportunity.OpportunityOwnerName #else Opportunity Owner Name: Not available #end

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

SanfordWhiteman
New Participant
August 4, 2023

You seem to be guessing at property names, which is quite strange? When you drag a field onto the Script Editor canvas, you always know the exact Velocity property name, so I don’t know where you’re coming up with this code.

 

There’s no property of the $lead called Opportunity that’s a simple object. That wouldn’t make sense because Lead:Opportunity is a one:many relationship.

 

The correct object is $OpportunityList. It’s not a property of the $lead, and it’s a List, not an object/Map, because of the many:one.

 

You can iterate over all the opportunities and their checked-off fields like this:

#if( !$OpportunityList.isEmpty() ) #foreach( $oppty in $OpportunityList ) #foreach( $key in $oppty.keySet() ) $key $oppty[$key].class $oppty[$key] #end #end #end