How do you access the most recent item in a custom object? | Community
Skip to main content
July 5, 2018
Question

How do you access the most recent item in a custom object?

  • July 5, 2018
  • 1 reply
  • 4349 views

We use custom objects to store data pertaining to our customers' homes.

Since a customer could own more than one home, the result is multiple items (or homes) in the "propertyDetails" custom object.

Whenever I use scripted email tokens to populate an email with this data, it uses the oldest item.

Here's the Velocity script that Marketo uses by default:

${propertyDetails_cList.get(0).streetAddress}

Can this script be changed to reference the most recent item's Street Address?

Thanks in advance!

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
July 5, 2018

See here: https://blog.teknkl.com/tip-switch-trigger-and-batch-object/

And also, if you're getting your feet wet with Velocity, all of these: https://blog.teknkl.com/tag/velocity/

July 5, 2018

Hi Sanford,

Thanks for your response. I'm not 100% sure how your blog post applies to my situation, or what to take away from it.

Would you mind explaining how this can be accomplished?

SanfordWhiteman
Level 10
July 5, 2018

The post explains how to sort the list, descending, by a datetime field (a field that's on every record, like updatedAt or any other field you want) and take the first item in the  sorted list.

That's exactly what gets you "the most recent item" in Velocity.