How to reference Custom Objects in Velocity Script | Community
Skip to main content
March 20, 2015
Solved

How to reference Custom Objects in Velocity Script

  • March 20, 2015
  • 6 replies
  • 4920 views
Hi,

Trying to figure out how to use the velocity script with custom objects, while the documentation does work with Custom Objects, it is not clear how can I get the array of custom objects, (and their attributes) in a Velocity Script. Where can I find the name of the objects? I have tried doing a drag and drop, but nothing happens.
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
Use #set command like

#set ($EventList = <<drag the custom object from Right hand side here>>

Hope this helps.

Rajesh

 

6 replies

March 25, 2015
I worked extensively on velocity scripts and marketo custom objects. The documentation at http://developers.marketo.com/documentation/email-scripting/
works for me.

I am not sure what do you mean by getting the array of custom objects. Does your business case needs to iterate throught all the records a lead have in the custom object associated with that lead? 
The name of the object is visible on the right hand side of the 'email script token' window. Make sure you 'check' each field you want to use in your script. If you do not, the script fails without throwing any error.

Please feel free to reach out if you need any pointers.

Rajesh Talele
 
April 1, 2015
Thanks Rajesh,

Yes, kinda like the example we have in the link you referred, I want to iterate over all the custom objects a lead has, in the example you see this line:
#foreach( $event in $EventsList )
That means $EventsList is an Array containing all the events the lead has attended. How do I get that $EventsList? I have tried dragging the Event object (my custom object is named differently, but the principle is the same). Is there an initialization I am missing? Any help will be appreciated. Thanks again!
Accepted solution
April 1, 2015
Use #set command like

#set ($EventList = <<drag the custom object from Right hand side here>>

Hope this helps.

Rajesh

 
April 1, 2015
Thanks Rajesh,

For some reason the drag and drop didn't work correctly in Chrome, I was working in Firefox and worked like a charm!
April 21, 2015
Hi Rajesh, 

I have a related question. We have a custom object for a Lead's "Account Manager". That object has a handful of fields (email address, name, etc), but these are not available for us to "check"... I'm trying to reference these fields in an email we're building. To your knowledge, can we use Velocity to access these?

I understand that the documentation indicates you have to able to see/check the object, but in the "Helpful Hints" it also makes reference to being able to access "first and second level objects connected to Lead or Account" (below).

http://developers.marketo.com/documentation/email-scripting/
"You can reference first and second level custom objects that are directly connected to the Lead or Contact. However, you cannot reference third level objects or custom objects associated with the Account."

Thanks!
April 21, 2015

Hi Jason,

Support for Account custom objects was introduced in Jan this year. So you should be able to use these fields in Marketo.

Can you confirm that the SFDC user used by Marketo for integration can indeed see this custom object?
May be Marketo does not have access to read this custom object in SFDC. I think most likely this might be an isse.

If that is fine, I think this will need some investigation. Marketo support would be able to help.

Hope this helps
 

Rajesh