Skip to main content
Jul 5, 2018 7:18 PM UTC
Question

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

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.

12 replies

SanfordWhiteman
User Group Leader
User Group Leader
Jul 5, 2018 7:37 PM UTC

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/

Translate
Jul 5, 2018 9:15 PM UTC

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?

Translate
SanfordWhiteman
User Group Leader
User Group Leader
Jul 5, 2018 9:26 PM UTC

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.

Translate