Requesting all records from a Custom Object - Velocity Script | Community
Skip to main content
May 1, 2017
Solved

Requesting all records from a Custom Object - Velocity Script

  • May 1, 2017
  • 1 reply
  • 2641 views

We are trying to come up with a Velocity Script to display all records from a Custom Object.

We have Subscribers (leads) with 1, 2, 3 or more  Beneficiaries in a Custom Object. Our email message should look like this:

Dear <Subscriber Name> .
Here is the info about your Beneficiaries:

Beneficiary 1 Name
Beneficiary 1 Plan #

Beneficiary 2 Name
Beneficiary 2 Plan #

Beneficiary 3 Name
Beneficiary 3 Plan #


I tried to use the following script for this:

${beneficiary_cList.get(0).beneficiaryFirstName}
${beneficiary_cList.get(0).beneficiaryPlanNumber}

${beneficiary_cList.get(1).beneficiaryFirstName}
${beneficiary_cList.get(1).beneficiaryPlanNumber}

${beneficiary_cList.get(2).beneficiaryFirstName}
${beneficiary_cList.get(2).beneficiaryPlanNumber}

However, if a Subscriber has less than 3 records in a Beneficiary Custom Object, this script would return an error and the email won't be delivered.

Is there another solution for this?

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 Grégoire_Miche2

HI Olga,

You will have to loop through the list instead, using a "#foreach($event in $ObjectList)" instruction. ALso, remember that every custom object has a list attached to it, with the name of <objectName>List.

Look at http://developers.marketo.com/email-scripting/examples/  for a code example.

Please not that Marketo will not retrieve more than 10 custom objects for each lead, though.

-Greg

1 reply

Grégoire_Miche2
Grégoire_Miche2Accepted solution
Level 10
May 1, 2017

HI Olga,

You will have to loop through the list instead, using a "#foreach($event in $ObjectList)" instruction. ALso, remember that every custom object has a list attached to it, with the name of <objectName>List.

Look at http://developers.marketo.com/email-scripting/examples/  for a code example.

Please not that Marketo will not retrieve more than 10 custom objects for each lead, though.

-Greg

May 1, 2017

Thanks, Greg!

You are always very helpful and super quick with response!

Grégoire_Miche2
Level 10
May 1, 2017

You are welcome