[SalesForce] Triggered Send from Salesforce using Marketing Cloud

We are using PersonAccount in our Salesforce org. We have also installed and configured the Marketing Cloud Connector. Our website inserts records into Salesforce whenever someone purchases a subscription to our product. Because of technical limitations of the third party we are using for managing subscription, we have to run a nightly job to update Salesforce with subscription related information. Now, we want to send a triggered email whenever the field "subscription status" gets updated. I have a couple of questions:

  1. We want to avoid having to send duplicate emails. We only want to send the email the first time the "subscription status" field gets updated. Our nightly job updates all records every time. Knowing this, what is the best way to achieve this using the triggered send configuration in Salesforce.

  2. Below are the "trigger" and "Apex Test Class" that I have created to get this going. Do I need to do anything else?

Trigger:

trigger Trig_Account on Account (after insert, after update) {
    et4ae5.triggerUtility.automate('Account');
}

Apex Test Class:

@isTest
private class Trig_AccountTest {
    static testMethod void myUnitTest() {
        Account testAccount = new Account(LastName = 'Test Account', PersonEmail = 'testclass@crtv.com');
        insert testAccount;
        testAccount = [select Id, LastName from Account where id = :testAccount.Id];
        System.assertEquals(testAccount.LastName, 'Test Account');
    }
}

Best Answer

In my opinion the easiest way to implement this functionality is building a Journey for this purpose. Using an entry event of the type "Salesforce Data" that is triggered on updates of the specific field in PersonAccounts, filtered by your criteria would make sure only the desired accounts enter the journey. Under "Settings -> Contact Entry" in the journey, you can set "Contract Re-Entry" to "No re-entry", so users don't get the email more than once. The only activity in your journey would be a "Send Email" activity for the triggered send.

Helpful resources:

Edit: There are some limitations with the Salesforce Data Entry Event, if you bulk-update records in Sales Cloud. You could then hit the APEX governor limits. As it seems your use case doesn't require an immediate trigger and this bulk-updates could be a problem, you could select the updated records using a SQL query activity in an automation, that then triggers the journey which includes the send email activity. Journey re-entry mode would be "No re-entry".

--> For further information check out the "APEX Governor Limits"-section in the "Salesforce Data Event" documentation article.

Related Topic