First, create your trigger on the Contact object. This must be named "Trig_Contact". Follow these instructions.
OK. Now I'm assuming you did this in a dev org since you can't create it in production. At this point, you're probably wanting to deploy your simple trigger to production so you can go on and create your send definition. Here's where you run into a problem. Salesforce kind of forgets to mention you need a test class. To make matters worse, you might not be an APEX developer... so this is going to be fun.
If you want some background on test classes, read this help article.
Back already? Awesome. Let's get to it and create that test class.
- From Setup, enter Apex Classes in the Quick Find box, then select Apex Classes and click New.
- In the class editor, add the code below as the class definition, and then click Save.
@isTestGreat. Your all set. Now you need to make a changeset with your Contact trigger and test class. Upload that changeset to Production. Go into Production and deploy the changeset. Make sure, when deploying, to select the last option to only test items in the changeset.
private class Trig_ContactTest {
static testMethod void myUnitTest() {
// TO DO: implement unit test
Contact testContact = new Contact(LastName = 'Test Contact', Email ='help@chrisbeckworth.com');
insert testContact;
testContact = [select Id, LastName from Contact where id = :testContact.Id];
System.assertEquals(testContact.LastName, 'Test Contact');
}
}
Here's how to set up the send definition.
Here's more info on triggered sends in general.