Re: Velocity Script using Salesforce Custom Object

Ayush_Aggarwal1
Level 2

Velocity Script using Salesforce Custom Object

Hi Marketo Users,

I have a case wherein I want to create a velocity script to populate the Account Team member name in the From field of the email. This information is available at the Account level in SFDC as a custom object. I can sync in the Custom object into Marketo, but want to leverage the information at the custom object into the velocity script.

Can anyone please help me on how can I build a velocity script using Salesforce Custom Objects?

Regards,

Ayush Aggarwal

7 REPLIES 7
SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity Script using Salesforce Custom Object

This isn't really a question about "Salesforce Custom Objects". It's specific to your Custom Object, which appears to have a 2nd-level relationship to the Contact.

If you do see this CO in Smart List filters, but do not see it in the Velocity field tree (on the right-hand side of Script Editor) then it can't be accessed from Velocity.

2nd-level Custom Objects are typically not accessible (some 2nd-level system objects are still available, for example an Oppty is technically a 2nd-level relationship).

Ayush_Aggarwal1
Level 2

Re: Velocity Script using Salesforce Custom Object

Hi Sanford Whiteman‌,

Yes, the Salesforce custom object appeared in the velocity script editor. I am trying to pull the Account team member name from the custom object, but the field is not available at the object. Below you find the screenshot for the same.

Screen Shot 2019-11-21 at 11.29.47 AM.png

I want to use the Account Team member name and email address as the sender name and from email address in the emails. However, both the fields are not available at the custom object. Also, there is another condition, the name and email address should only populate if the "Team Role" is "Customer Success Representative". I know it's commented in there since I was still trying to fetch the name and email address for the account team member.

Any help here is appreciated.

Regards,

Ayush Aggarwal

SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity Script using Salesforce Custom Object

Well, to begin with, that #foreach wouldn't make sense even if the property were exposed in Velocity. You're looping over the list and then get-ting (or trying to get) the Name property of the first item in the list, regardless of which item you're currently looking at.

But to the point of the Name property not being in the Script Editor tree, there are 2 possible explanations:

  • you're mistaking it for a field on this CO, it's actually a field on another related CO
  • your API user doesn't have access to read this field
Ayush_Aggarwal1
Level 2

Re: Velocity Script using Salesforce Custom Object

Thank you Sanford!

I believe it's the first case, since they are users in SFDC and users info in Marketo are not available. Got to know from this idea thread and post.

 

https://nation.marketo.com/thread/33692-marketo-salesforce-integration-needs-a-serious-overhaul-dont... 

Regards,

Ayush Aggarwal

SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity Script using Salesforce Custom Object

Yes, the link back to the users table isn't going to work. The field would have to be mapped to the first-level object (Account Team Member).

If you had a slowly-changing set of ID→Name mappings, you could store the mappings in a standalone Velocity token, then look up the ID in it. However, unless the mappings change so rarely that someone could manually update that token (like once a month), you'd need to automate populating that token via API, which is its own development effort.

Julia_Rosentha3
Level 2

Re: Velocity Script using Salesforce Custom Object

Hey Sanford Whiteman, just wondered what the best work around is for accessing info that typically lives in CO's in Salesforce, in Marketo. At the moment, we create new custom fields in the Contact object and transfer the data there.

But when I was using Sugar CRM I used to be able to "mirror" a field from one object into another. Not for the purpose of Marketo visibility, but thats beside the point. The end result was the Primary field remained in the right location, but the info was also visible in a second location, in the form of an uneditable field. If the data changed in the primary, it would auto update the secondary.

Does the same function exist in Salesforce? And, is that a good solution to make data visible in Marketo? i.e. have the primary field in the contact and secondary field in the custom object so CRM users can still see the info in the right place. 

I've heard it's possible by way of Lookup fields but I don't really understand them.

SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity Script using Salesforce Custom Object

You can do that same kind of thing -- map the field from one object to another, so it's on the flatter/nearer object. However, this doesn't make sense in the case of many-to-one relationships.