SOLVED

Requesting all records from a Custom Object - Velocity Script

Go to solution
Anonymous
Not applicable

Requesting all records from a Custom Object - Velocity Script

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Grégoire_Miche2
Level 10

Re: Requesting all records from a Custom Object - Velocity Script

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

View solution in original post

3 REPLIES 3
Grégoire_Miche2
Level 10

Re: Requesting all records from a Custom Object - Velocity Script

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

Anonymous
Not applicable

Re: Requesting all records from a Custom Object - Velocity Script

Thanks, Greg!

You are always very helpful and super quick with response!

Grégoire_Miche2
Level 10

Re: Requesting all records from a Custom Object - Velocity Script

You are welcome