SOLVED

Re: How can I personalize email according to contact's Account Owner using Velocity Script?

Go to solution
freeza
Level 3

How can I personalize email according to contact's Account Owner using Velocity Script?

I have to send a personalized email to contacts according to who their Account Owner is.

These fields will be changing according to their account owner. 

From Name

From Address

Reply to Address

Signature

 

Can I know how this can be archived using velocity Script. 

For example we can use these 2 Account owners that's located under these fields.

[$company.accountOwnerFirstName] [$company.accountOwnerLastName]

Silvia Alex

Ben Ford

 

Thank You!

3 ACCEPTED SOLUTIONS

Accepted Solutions
Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: How can I personalize email according to contact's Account Owner using Velocity Script?

Apologies if I'm missing out on anything here, but you could directly use the Account Owner tokens instead of adding account field values using a velocity script.

Darshil_Shah1_0-1675791979702.png

You'd need velocity if you'd like to populate lead owner/other catch-all details in case a person doesn't have an account owner. Is that your requirement?

 

View solution in original post

Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: How can I personalize email according to contact's Account Owner using Velocity Script?

You could refer to this article by Sandy where-in he has added the script to use the lead owner values in case the account owner data is absent. You could use it as a reference and update it according to your use case, i.e., use the general email with the team names. Let us know if you need any help in making the updates.

 

View solution in original post

SanfordWhiteman
Level 10 - Community Moderator

Re: How can I personalize email according to contact's Account Owner using Velocity Script?

There’s nothing syntactically wrong with the code above, but I have no idea where you’re getting the object name $company and the property name AccountOwnerFirstName from. You should be dragging the required fields from the tree on the right of Script Editor onto the canvas, which tells you their Velocity name, for example $lead.Account_Owner_First_Name is a standard Velocity name.

View solution in original post

10 REPLIES 10
Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: How can I personalize email according to contact's Account Owner using Velocity Script?

Apologies if I'm missing out on anything here, but you could directly use the Account Owner tokens instead of adding account field values using a velocity script.

Darshil_Shah1_0-1675791979702.png

You'd need velocity if you'd like to populate lead owner/other catch-all details in case a person doesn't have an account owner. Is that your requirement?

 

freeza
Level 3

Re: How can I personalize email according to contact's Account Owner using Velocity Script?

Oh right! That didn't go through my head. Thank You!

 

But yeah I do have a general one too. If the contact's account owner is neither of the 2 and someone else then their email should be personalized as a general email with team names. 

Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: How can I personalize email according to contact's Account Owner using Velocity Script?

You could refer to this article by Sandy where-in he has added the script to use the lead owner values in case the account owner data is absent. You could use it as a reference and update it according to your use case, i.e., use the general email with the team names. Let us know if you need any help in making the updates.

 

freeza
Level 3

Re: How can I personalize email according to contact's Account Owner using Velocity Script?

When I tried to do what in the stated script it wasn't working properly.

 

Is it possible to put a new script here where if the Account owner of the contact equals to either 

Silvia Alex OR

Ben Ford

(Email should show their name and address under the From and signature section) Or else if the account owner is neither of them it should show 

UT Team as the signature and the From name.

How can I script this out?

SanfordWhiteman
Level 10 - Community Moderator

Re: How can I personalize email according to contact's Account Owner using Velocity Script?

Please post what you’ve tried. It’s best to learn how the code works (or doesn’t) and you shouldn’t be comfortable deploying Velocity tokens that you don’t understand at least at a high level.

 

freeza
Level 3

Re: How can I personalize email according to contact's Account Owner using Velocity Script?

Sure, here's what I have tried.

 

 

 

 

 

 

#if ( $company.accountOwnerFirstName.equals("Nicole"))
#set ( $accountOwnerDetails = {
	"from": "Nicole Forbes",
	"fromAddress":"nforbes@test.com" ,
        "replyToAddress":"nforbes@test.com",
        "signature": "Nicole Forbes"
        }
       )
#elseif ( $company.accountOwnerFirstName.equals("Ben"))
#set ( $accountOwnerDetails = {
	"from": "Ben Ferdon",
	"fromAddress":"bferdon@test.com" ,
        "replyToAddress":"bferdon@test.com",
        "signature": "Ben Ferdon"
        }
       )
#else
#set ( $accountOwnerDetails = {
       "from": "Partner Team",
	"fromAddress":"info@test.com" ,
        "replyToAddress":"info@test.com",
        "signature": "Partner Team"
        }
       )
#end
       
#set( $aAccountOwner = $accountOwnerDetails[$company.accountOwnerFirstName])
${aAccountOwner.from}
${aAccountOwner.fromAddress}
${aAccountOwner.replyToAddress}
${aAccountOwner.signature}

 

 

 

 

 

freeza
Level 3

Re: How can I personalize email according to contact's Account Owner using Velocity Script?

I also tried these two ways this way to get the signature printed just for testing purposes to see whether I am getting any results but for some reason it's not working properly. It's only giving me the else results eventho I am testing a lead with the if and the elseif statement.

 

#if($company.AccountOwnerFirstName.equals("Nicole"))
	#set($signature = "Nicole Forbes")
#elseif($company.AccountOwnerFirstName.equals("Ben"))
	#set($signature = "Ben Ferdon")
#else
	#set($signature = "Partner Team")
#end
##print the greeting and some content
${signature}

 

 

 

Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: How can I personalize email according to contact's Account Owner using Velocity Script?

What do you see when you print just the token in the velocity for this record?

 

SanfordWhiteman
Level 10 - Community Moderator

Re: How can I personalize email according to contact's Account Owner using Velocity Script?

There’s nothing syntactically wrong with the code above, but I have no idea where you’re getting the object name $company and the property name AccountOwnerFirstName from. You should be dragging the required fields from the tree on the right of Script Editor onto the canvas, which tells you their Velocity name, for example $lead.Account_Owner_First_Name is a standard Velocity name.