Populating an email with custom object data that was triggered by a custom object data update. | Community
Skip to main content
Aug 15, 2017 1:45 AM UTC
Solved

Populating an email with custom object data that was triggered by a custom object data update.

Hello,

Marketo has a new feature that allows you to trigger an action based off of a custom object change.  Trigger Off Custom Object Changes - Marketo Docs - Product Docs

I need to populate a triggered email with the custom object data specific to the custom object change.  Normally, you can use $!{TriggerObject.CDOField} to populate triggered campaigns, but according to Marketo Support, velocity script does not work with custom object changes at this time.  Is there a workaround where I can pull specific fields from the CDO record that triggered the campaign?

Thanks!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
Aug 15, 2017 6:53 AM UTC

You don't need that backwards loop -- that's for reverse()ing an ArrayList based on natural index order.

To sort on updatedAt ​use SortTool:

#set( $sortedList = $sorter.sort($ObjectList,["updatedAt:desc"]) )

The filter you should do by declaring another ArrayList and populating it (we can't use actual filter predicates like in Java):

#set( $filteredList= [] )

#foreach( $itm in $sortedList)

#if( $itm.Field1 == "Published" )

#set( $tmp = $filteredList.add( $itm ) )

#end

#end

9 replies

SanfordWhiteman
Level 10
Aug 15, 2017 2:07 AM UTC

If not surfaced as {{TriggerObject}}, you have to filter the ArrayList (of 10 custom objects) to get the most recently updated based on updatedAt or equivalent timestamp on the object itself.

Translate
Aug 15, 2017 4:07 AM UTC

Hey Sanford,

How would I go about doing that?  Can you show some sample code?  I would need to sort the ArrayList and also filter based on certain CDO field criteria (i.e. Field1=Published).

I've seen this snippet you wrote for someone else:

  1. ## You can also use this var to hold the default event 
  2. #set( $lastInterestingEvent = {} ) 
  3. ## Guard against bad inputs (null or empty object list) 
  4. #if( $EventList && !$EventList.isEmpty() ) 
  5.     ## Loop backwards through ArrayList (standard foreach is fwd only) 
  6.     #foreach( $idx in [$math.sub($EventList.size(),1)..0] ) 
  7.         #set( $event = $EventList[$idx] ) 
  8.         #if( !$event.partnerURL.isEmpty() ) 
  9.             #set( $lastInterestingEvent = $event ) 
  10.             #break($foreach) 
  11.         #end 
  12.     #end 
  13. #end 
  14. Partner URL is: ${lastInterestingEvent.partnerURL} 

I found this very helpful, but would love to see how to edit it to sort by updatedAt and Field1=Published

Thanks!

Translate
SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
Aug 15, 2017 6:53 AM UTC

You don't need that backwards loop -- that's for reverse()ing an ArrayList based on natural index order.

To sort on updatedAt ​use SortTool:

#set( $sortedList = $sorter.sort($ObjectList,["updatedAt:desc"]) )

The filter you should do by declaring another ArrayList and populating it (we can't use actual filter predicates like in Java):

#set( $filteredList= [] )

#foreach( $itm in $sortedList)

#if( $itm.Field1 == "Published" )

#set( $tmp = $filteredList.add( $itm ) )

#end

#end

Translate