function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
CRTV MC Tracking UserCRTV MC Tracking User 

Triggered Send from Salesforce using Marketing Cloud

Hi,
A salesforce newbie here.  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');
}


 
Brian Cherry FWIBrian Cherry FWI
I would have the trigger update a checkbox on the Account record that the email is sent. then on the trigger do an IF statement to check if that box is true or false and process.

You'll also want to bulkify the trigger. Here's an example of a bulkify. You'll want to change your trigger to be before update and before insert so you can update the record and check your box.
trigger NewAccountSetup on SFDC_Project__c (before update, before insert) {

    for(SFDC_Project__c inst: Trigger.new)
    {
       IF(inst.form_assembly_trigger__c == true)
    {
    string accupdate = 'Content Store; ';
   
    if(inst.Request_Content_Store__c == true)
    {
    accupdate = accupdate + 'Content Store;';
    inst.Request_Content_Store__c = true;
    }
    else
    {
    inst.Request_Content_Store__c = false;
    }
   
    if(inst.Request_Drive__c == true)
    {
    accupdate = accupdate + 'FWI Drive;';
    inst.Request_Drive__c = true;
    }
    else 
    {
    inst.Request_Drive__c = false;
    }
    if(inst.Request_FWI_Store__c == true)
    {
    accupdate = accupdate + 'FWI Store;';
    inst.Request_FWI_Store__c = true;
    }
    else 
    {
   inst.Request_FWI_Store__c = true;
    }
       if(inst.Request_IF__c == true)
    {
    accupdate = accupdate + '; Integration Framework 5.0';
    inst.Request_IF__c = true;
    }
    else 
    {
   inst.Request_IF__c = false;
    }
    if(inst.Request_IF__c == true)
    {
    accupdate = accupdate + '; Tech Support Page';
    inst.Request_IF__c = true;
    }
    else 
    {
    inst.Request_IF__c = false; 
    }
        if(inst.Requested_Bing__c == true)
    {
    accupdate = accupdate + '; Bing';
    inst.Requested_Bing__c = true;
    }
    else 
    {
    inst.Requested_Bing__c = false; 
    }
    inst.Customer_Accouts__c = accupdate;
        inst.form_assembly_trigger__c = false;
    }
        else {
            
        }
    }
    
}