You need to sign in to do that
Don't have an account?
Susan Linck
Trigger in Sales Cloud to send email via Marketing Cloud
I need a trigger to send an email from SF to Exact Target using the integration. The documentation for the integration provides the following code for the trigger- but it is wrong, or at least can't get it to save.
Object Name.trigger Trig_Object Name on Object Name (after insert, after update) {
et4ae5.triggerUtility.automate('Object Name'); }
For example:
trigger Trig_Lead on Lead (after insert, after update) {
et4ae5.triggerUtility.automate('Lead');}
This will be on the Contact object for a "Consumer" RT, so I think I need to have it be something like this:
trigger Trig_Contact on Contact (after insert, after update) {
for(Contact consumer : Trigger.new) {
if (consumer.Type == 'Consumer')
{et4ae5.triggerUtility.automate('Contact');
}}}
Do I need the for loop?
The use case is when a new Contact is created with a WFR to send an acknowledging email to the Contact (for a warranty registration).
This is my first crack at writing a trigger, I'm the Admin. I haven't seen how to use something like et4ae5.triggerUtility.automate.
Thanks.
Object Name.trigger Trig_Object Name on Object Name (after insert, after update) {
et4ae5.triggerUtility.automate('Object Name'); }
For example:
trigger Trig_Lead on Lead (after insert, after update) {
et4ae5.triggerUtility.automate('Lead');}
This will be on the Contact object for a "Consumer" RT, so I think I need to have it be something like this:
trigger Trig_Contact on Contact (after insert, after update) {
for(Contact consumer : Trigger.new) {
if (consumer.Type == 'Consumer')
{et4ae5.triggerUtility.automate('Contact');
}}}
Do I need the for loop?
The use case is when a new Contact is created with a WFR to send an acknowledging email to the Contact (for a warranty registration).
This is my first crack at writing a trigger, I'm the Admin. I haven't seen how to use something like et4ae5.triggerUtility.automate.
Thanks.
Getting the Custom APEX Trigger to save is certainly not as easy as they make it seem in the documentation, is it? I had to fight with this quite a bit too.
One thing that is not mentioned in the documentation is that you have to create Custom APEX Class that is a test class to test your trigger code in addition to the trigger code itself.
Here is a copy of the test class I used when I created my lead trigger:
As for your trigger code itself, I would suggest simplifying it so that it just applies to all Leads and then just set the criteria for the triggered send when you create the triggered send. Here is my trigger code.
So, save the test class first, then the trigger. If you are deploying via the Force.com IDE then you can deploy them as part of the same package.
Once they are deployed you can go to the Marketing Cloud tab and then to the "Configure..." link and you will see the "Triggered Sends" option. You will create your whole triggered send definition from here, including selecting the email and delivery profile and setting the conditions for when to send an email. So this is where you would set the criteria for Type = Consumer.
Once you activate your triggered send in salesforce you will see the send definition show up your Marketing Cloud account in the Triggered Sends folder as usual.
Hope this helps!
~Josiah Kaiser
All Answers
Getting the Custom APEX Trigger to save is certainly not as easy as they make it seem in the documentation, is it? I had to fight with this quite a bit too.
One thing that is not mentioned in the documentation is that you have to create Custom APEX Class that is a test class to test your trigger code in addition to the trigger code itself.
Here is a copy of the test class I used when I created my lead trigger:
As for your trigger code itself, I would suggest simplifying it so that it just applies to all Leads and then just set the criteria for the triggered send when you create the triggered send. Here is my trigger code.
So, save the test class first, then the trigger. If you are deploying via the Force.com IDE then you can deploy them as part of the same package.
Once they are deployed you can go to the Marketing Cloud tab and then to the "Configure..." link and you will see the "Triggered Sends" option. You will create your whole triggered send definition from here, including selecting the email and delivery profile and setting the conditions for when to send an email. So this is where you would set the criteria for Type = Consumer.
Once you activate your triggered send in salesforce you will see the send definition show up your Marketing Cloud account in the Triggered Sends folder as usual.
Hope this helps!
~Josiah Kaiser
I used the code you posted above and I was able to successfully Activate the triggered sends I set up on the Lead object. I'm trying to create the Apex class and trigger for the Campaign Members object, but haven't been able to edit the code above to save correctly in order to activate it.
I've posted this question (https://developer.salesforce.com/forums/ForumsMain?id=906F0000000MJ6u) but was hoping you may have some insight based on your reply to this post.
Thank You,
Vicky