SOLVED

Velocity script to retrieve latest custom object field

Go to solution
Anonymous
Not applicable

Velocity script to retrieve latest custom object field

Hi all,

I am currently having trouble trying to retrieve the latest custom object added.

As an example,

When someone lists their vehicle onto our platform a custom object 'Vehicle' is attached to the lead with a Listing ID.

I want to get that ID to use in a link in the email.

However I need it to return the latest custom object listing ID.

From researching i see that something like this will work, however I am trying to fit mine into it.

I am finding it difficult to fit it in ${Listing_cList.get(0).listingID}

  1. #if( $Listing && !$Listing.isEmpty() ) 
  2. #set( $firstItem = $Listing[0] ) 
  3. #set( $lastItem = $[$math.sub($Listing.size(),1)] ) 
  4. #end 

Thanks for your time and effort to read through

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity script to retrieve latest custom object field

This code makes little sense, I must say. $Listing is not the name of your list of Listings and wishing won't make it so.

Please read this post: http://blog.teknkl.com/tip-switch-trigger-and-batch-object/

View solution in original post

5 REPLIES 5
SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity script to retrieve latest custom object field

This code makes little sense, I must say. $Listing is not the name of your list of Listings and wishing won't make it so.

Please read this post: http://blog.teknkl.com/tip-switch-trigger-and-batch-object/

Anonymous
Not applicable

Re: Velocity script to retrieve latest custom object field

Hi there,

Sorry i should have clarified, that was just an example 'Listings' does not exist.

It's okay, thank you for that post! I will try to figure it out ^_^

Shayla_McKnight
Level 2

Re: Velocity script to retrieve latest custom object field

Hey Andrew,

Curious if you found your answer. I tried velocity scripting yesterday to pull the most recent order number from a custom object and it worked for me. The only thing I see missing from your velocity scripting below is the variable you want it to return. For example with my scripting I wanted order number so right below #end I put $lastItem.OrderNumber. Let me know if that helps.

SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity script to retrieve latest custom object field

Andrew's VTL is not actually runnable (it doesn't contain the real names of the ArrayLists).

The correct way to pull the last update is in the blog post above (assuming the "most recent order number" means the "the order number of the most recently updated object" which is not always the case).

Anonymous
Not applicable

Re: Velocity script to retrieve latest custom object field

Hi Shayla,

Yes, the VTL I wrote was just an example of what i thought was possibly right, the arraylist was not real.

I was basically just asking how to do it, I believe the correct way is the post that Sanford provided.