Populating an email with custom object data that was triggered by a custom object data update. | Community
Skip to main content
August 15, 2017
Solved

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

  • August 15, 2017
  • 1 reply
  • 3967 views

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.
Best answer by SanfordWhiteman

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

1 reply

SanfordWhiteman
New Participant
August 15, 2017

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.

August 15, 2017

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!

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
August 15, 2017

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