Velocity Script - Find most recent complete record - HELP | Community
Skip to main content
Douglas_Meierdi
Level 2
September 19, 2017
Question

Velocity Script - Find most recent complete record - HELP

  • September 19, 2017
  • 1 reply
  • 3827 views

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="${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?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

SanfordWhiteman
Level 10
September 19, 2017

What are the field(s) that signify a completed transaction? Does the mere existence of the ​attorneyId property on the job ​determine that the job is complete? Or must ​attorneyId, attorneyName, ​and/or some other fields all be non-empty?

Douglas_Meierdi
Level 2
September 19, 2017

Correct - if the attorneyId is present, they've been hired and attorneyName and attorneyImage would also be populated.

Douglas_Meierdi
Level 2
September 19, 2017

Also - currentstatus would be "completed_and_paid"