Re: Using the triggerobject reference in a velocity script

Anonymous
Not applicable

Using the triggerobject reference in a velocity script

Hi all,

I am trying to use the TriggerObject reference to use trigger objects fields in an emai, as stated on developers.marketo.com and I cannot figure out how this is suposed to work.

I have a custom object (Demande__c) linked to the lead. When a new Demande__c in inserted, I want to send out an email with some fields of this instance of the object. I use the "Added to Demande" trigger to trigger a campaign that send this email.

The tricking thing is that the lead can have many instances of the object Demande__c and what I need is to get precisely the one that triggered the campaign. For this, I have used the TriggerObject reference. My script is :

<table>
<tr><td>Last Name : </td><td>${lead.LastName}</td></tr>
<tr><td>Type de demande : </td><td>${TriggerObject.Type_de_demande__c}</td></tr>
<tr><td>Date/heure de la demande : </td><td>${TriggerObject.Date_Heure_de_la_demande__c}</td></tr>
</table>
If I check the Type_de_demande and Date_Heure_de_la_demande__c in the script editor right column, I get an error. If I don't I get the email with the variable names still in it.

Can anyone help?

On a more global point of view, having various and comprehensive code samples on the developers site would be welcome...

Thanks in advance,
Greg
Tags (1)
5 REPLIES 5
Anonymous
Not applicable

Re: Using the triggerobject reference in a velocity script

High-level, your use case is exactly why we built the trigger object feature, so we should be able to get this to work. What error are you getting when you check those fields?
Anonymous
Not applicable

Re: Using the triggerobject reference in a velocity script

Hi Erik,

The message is : 

Error approving test de demandes.Réponse à demande avec Velocity — Too many association maps for ext object with name salesforce.com Demande__c

Which in my understanding seems to refer to the fact that each lead may have multiple Demande__c... Yet the only one I am interested in is the one that triggered the smart campaign.

Thanks for your help,
Greg
Anonymous
Not applicable

Re: Using the triggerobject reference in a velocity script

BTW, Erik, I can give you access to the customer instance on which this happens, if you want. Just email me privately.

Best regards,
Greg
Anonymous
Not applicable

Re: Using the triggerobject reference in a velocity script

I've seen that message before if the link between the Object and SFDC isn't a supported one. Does this work if you access the object directly rather than use the Trigger contruct?

Also, I don't think I have your email- can you send me what the instance name is (I don't need a login) so we can look at it? I'm at erik@marketo.com
Anonymous
Not applicable

Re: Using the triggerobject reference in a velocity script

I need some help using this script as well. I have tried doing a really basic one where the trigger is "change data value" and I did it for the value last name on leads. I then created a script with this coding:
${TriggerObject.Email}
I also ticked email address on the lead field 

and put the token in the email which is sent as the flow action.

But I still just get ${TriggerObject.Email} in the email not the actually email address. What am I doing wrong??