Troubleshooting - Targeting Most Recent Custom Object

dbassett
Level 2

Troubleshooting - Targeting Most Recent Custom Object

Hi @SanfordWhiteman (or anyone else who has expertise in this area, feel free to reply), I recently read through some community posts about targeting the most recent data in a custom object, including this post from 2018-2019: https://nation.marketo.com/t5/product-discussions/how-do-you-access-the-most-recent-item-in-a-custom...

 

I also read the TEKNKL blog post https://blog.teknkl.com/tip-switch-trigger-and-batch-object/

 

I came to the following Velocity Script, which I tested in the Preview of the email with a relevant contact record:

#set( $dataByMostRecent = $sorter.sort($PAD_Metrics_v2_cList,"pad_load_date:desc") )
#set( $latestDataDetails = $dataByMostRecent[0] )
${latestDataDetails.pad_industry_assessment_1}

I have both pad_industry_assessment_1 and pad_load_date checkboxed in the custom object tree.

 

However, the email does not populate the data from the contact record for that field (it should show Network Fundamentals as the most recent data field output)  - it just shows the written-out variable in the email: 

${latestDataDetails.pad_industry_assessment_1}

Any ideas what I am missing or where I went wrong? Thank you in advance, I know that it's probably a question you get often. 

7 REPLIES 7
Jo_Pitts1
Level 10 - Community Advisor

Re: Troubleshooting - Targeting Most Recent Custom Object

@dbassett ,

I find that if Velocity is spitting out the variable as text, it means it isn't recognizing it as a variable.

 

Are you 100% sure you've got the casing and spelling right on variable name that you're outputting?

 

Can you paste in a screenshot showing the field names of the custom object?

 

Cheers

dbassett
Level 2

Re: Troubleshooting - Targeting Most Recent Custom Object

tree 1.pngtree 2.png

  

SanfordWhiteman
Level 10 - Community Moderator

Re: Troubleshooting - Targeting Most Recent Custom Object

Please include the unsorted, original list

$PAD_Metrics_v2_cList

in the received email and post the output.

dbassett
Level 2

Re: Troubleshooting - Targeting Most Recent Custom Object

Hi Sanford, I'm not sure I understand what you mean. Are you saying to paste

$PAD_Metrics_v2_cList

in the velocity script right before the variable? Seeking to understand what "include the original list in the received email" means. Thank you

dbassett
Level 2

Re: Troubleshooting - Targeting Most Recent Custom Object

@SanfordWhiteman just following up for clarification on your previous reply when you get a chance. Thanks!

SanfordWhiteman
Level 10 - Community Moderator

Re: Troubleshooting - Targeting Most Recent Custom Object

Yes, that’s what I meant, print the whole list (this is an essential part of troubleshooting!).
Jo_Pitts1
Level 10 - Community Advisor

Re: Troubleshooting - Targeting Most Recent Custom Object

@dbassett ,

Try it!