6 Replies Latest reply on Sep 19, 2017 2:13 PM by Sanford Whiteman

    Velocity Script - Find most recent complete record - HELP

    Doug Meierdiercks

      Hello Marketo Community -

      I'm trying to build a token to populate an email with information about the contractor the customer most recently worked with. The script references a custom object called "Job" which contains information about - you guessed it - a job. These are jobs created by customers and the customer doesn't always complete the transaction (i.e. hire a contractor).

       

      The script I have seems to find the first job record ever. What I need is a script that will find the most recent record where they actually hired someone. Here's what I have:

       

      #set($url = "www.upcounsel.com/jobs/new?aid=${jobList.get(0).attorneyId}")

      <p align="center">

        <img src="${jobList.get(0).attorneyImgUrl}" alt="" style="max-height:150px;max-width: 150px;border-radius:100%;"><br>

        <a href="https://${url}" style="margin-top: 15px; padding: 8px 20px; color: #ffffff; width: 175px; line-height: 30px; display: inline-block; text-align: center; font-family: Helvetica; text-decoration: none; background-color: #00C76B; border-radius: 3px;">

          Rehire ${jobList.get(0).attorneyName}

        </a>

      </p>

       

      So how do I get this script to A) Start with the last record and work backwards and B) evaluate the record to ensure that the fields it needs to pull are not blank?