Re: Velocity Script - Custom Account Object

Ryan_Miller
Level 1

Velocity Script - Custom Account Object

Hello, I'm new to Velocity scripting and have a general question.

We have a custom account object built in SFDC. This object is basically an extension of the account team where multiple product specialists are assigned to each account.  The object is sync'd to Marketo and I'm able to see the object and related fields. One of the fields on the object is 'Role'.  This field indicates the product specialty for each team member. 

I was hoping to have 'select' functionality within the scripting that would allow me to segment the team members I want to utilize within tokens.  However, the if/then logic I have been trying is ignored.

Is it possible to target specific records of the custom object and use their related attributes as tokens?

For example:

#if(${Account_Marketo_Team_Member__cList.get(0).Role__c} == "Sales Exec-ProductXX")

    #set (${Account_Marketo_Team_Member__cList.get(0).Basic_Name__c})

Result:

Returns the individuals name from the first row of the accounts custom object regardless of Role.

Thanks

Ryan

7 REPLIES 7
Justin_Cooperm2
Level 10

Re: Velocity Script - Custom Account Object

Did you ensure to check the checkbox of the custom object in the right-hand pane of the Email Script Token editor? Only checked objects will be available to you to iterate over within the script.

Ryan_Miller1
Level 1

Re: Velocity Script - Custom Account Object

Hi Justin.  Yes, the Role field of the custom object is checked.

Justin_Cooperm2
Level 10

Re: Velocity Script - Custom Account Object

Ryan,

Try changing the script:

#set ( $role = ${Account_Marketo_Team_Member__cList.get(0).Role__c} )

#if($role == "Sales Exec-ProductXX")

$role.Basic_Name_c

EDIT: ooops, I meant:

#set ( $member = ${Account_Marketo_Team_Member__cList.get(0)} )

#if($member.Role_c == "Sales Exec-ProductXX")

$member.Basic_Name_c

Ryan_Miller1
Level 1

Re: Velocity Script - Custom Account Object

Thanks Justin, I tried the script above and received an error in the delivery results.  Working off your suggestion I tried the following:

#set ( $role = ${Account_Marketo_Team_Member__cList.get(0).Role__c} )

#if($role == "Sales Exec-ProductXX")

${Account_Marketo_Team_Member__cList.get(0).Basic_Name__c}

#else

Nothing

#end

My test returned 'Nothing' in the token.  Obviously its not seeing the $role__c value or recognizing the name associated with it..  I can see the values on the lead record from the Activity log:

Basic Name:David Matthews

Account Marketo Team Member Name:MKTO-00003

Role:Sales Exec-ProductXX

System Modstamp:2016-02-02 09:41:46

Justin_Cooperm2
Level 10

Re: Velocity Script - Custom Account Object

Send me your munchkin ID and a link to the program and test email. jcooperman@marketo.com

Justin_Cooperm2
Level 10

Re: Velocity Script - Custom Account Object

Also, insted of 'Nothing' just print $role and see what it gives you.

Justin_Cooperm2
Level 10

Re: Velocity Script - Custom Account Object

We solved Ryan's problem. The script was missing a '_' from one of the variable names.