3 Replies Latest reply on May 1, 2017 1:21 PM by Grégoire Michel

    Requesting all records from a Custom Object - Velocity Script

    Olga Khadieva

      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?