SOLVED

Re: Velocity script support - Personalisation tokens from Custom Object entries.

Go to solution
Jo_Pitts1
Level 10 - Community Advisor

Re: Velocity script support - Personalisation tokens from Custom Object entries.

@PaddyRR ,

There are many baffling things in your statement most recent reply.  I'm going to try and unpack them all.

 


@PaddyRR wrote:

From what I understand the implement your solution the Script would need to be applied very specifically to emails, referencing the email HTML in the code itself. 

VTL only works with email (in the Marketo context at least).  Do you mean 'would need to be applied to specific emails'?

 

 


@PaddyRR wrote:

 

From what I understand the implement your solution the Script would need to be applied very specifically to emails, referencing the email HTML in the code itself. 

 


The output stage is only there as an example.  You can use the code as provided, strip the output stage and then have separate more email specific tokens to do the output.  I am now having to make a presumption that you only want to generate the output for the most recent enquiry.  If that presumption is correct, then something along these lines would work.

 

#set ($maxDevelopmentToDisplay = 1)
#set ($displayCounter = 0)

#set( $allDevelopments = {
  "Westley Green, Langdon Hills" : {
    "Development_Name":"Westley Green",
    "Development_Description":"XXX",
    "Development_Address":"XXX", 
    "Development_Brochure":"XXX", 
    "Development_PageURL":"XXX", 
    "Development_BookingURL":"XXX", 
    "Development_HeaderIMG":"XXX"
  },
  "Meadow View, Silver End" : {
    "Development_Name":"Meadow View",
    "Development_Description":"XXX",
    "Development_Address":"XXX", 
    "Development_Brochure":"XXX", 
    "Development_PageURL":"XXX", 
    "Development_BookingURL":"XXX", 
    "Development_HeaderIMG":"XXX"
  },
  "The Mulberries, Witham":{
    "Development_Name":"The Mulberries",
    "Development_Description":"XXX",
    "Development_Address":"XXX", 
    "Development_Brochure":"XXX", 
    "Development_PageURL":"XXX", 
    "Development_BookingURL":"XXX", 
    "Development_HeaderIMG":"XXX"
  }
  }
)

#set($enquiryListSorted = $sorter.sort($enquiry_cList, ["EnquiryDate:desc"]))

#foreach($enquiry in $enquiryListSorted )
  #if($enquiry.EnquiryOutletStatus.equals("Open"))
    #set($aDevelopment = $allDevelopments[$enquiry.enquiryOutletName] )
    #set ($displayCounter = $math.add($displayCounter ,1))
    #if ( $displayCounter.equals($maxDevelopmentToDisplay) )
      #break
    #end
  #end
#end

 

Put that token at the very top of your email (heck, you might even want to embed it in the template).

 

and as a separate token (or tokens) - create one per variable:

 

${aDevelopment.Development_Name}

 

That will output 100% unformatted text.  Insert that token inside any piece of HTML and it'll naturally take on that formatting.

 

There are further tricks you could do here to allow this to be used for single or multiple development enquiries and still separate the logic for working out what to output and the actual output, but I think we'll leave that for another day.

 


@PaddyRR wrote:

 

I wonder if you know of any way to make this work using something like the below? (P.s. This code still doesn't seem to pull the correct object info into the tokens)


Have you ensured all relevant fields have been ticked in the list on the RHS?  If not, the don't get passed into Velocity.  This is to help memory management.

 

I am wondering if @SanfordWhiteman's statement is correct.  You may need to seek internal help from someone with more years of dev experience or contract in someone with experience in this space.

 

Cheers

Jo