0

I"m working with a Process Builder, and I'm able to create a messages record on the opp that has tracking turned on, but when I send the test email from the Opportunity, everything works fine except for the tracking. Is this functionality only possible with Apex?

1

1 Answer 1

0

I've discovered that this is not possible with ProcessBuilder and the Email Alert alone. You have to use Apex on this but it's not that hard, and would actually be a good Admin Dev project if you're looking to jump into the Dev scene as an Admin.

You have to use these The Messaging.SingleEmailMessage Class and the code will look something like this....

Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); 

String templateId = [getYourTemplateIdFromYourEmailTemplates];
Opportunity opp = [Select Id, Customer_Contact__c from Opportunity WHERE Id = 'someOppId']; //Ideally this would be the one that is passed in from the process Builder   
    String[] toAddresses = new String[]{string.valueOf(opp.Custome__c)};   
    email.setCCAddresses(toAddresses);
    email.setSenderDisplayName('Spider-Man'); 
    //email.setSubject('Confirm Your Shipment'); 
    email.setTemplateId(Id.valueOf(templateId)); 
    email.setTargetObjectId(opp.Customer__c);
    email.setWhatId(Opp.Id); 
    email.setSaveAsActivity(true); 

Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});

Keep in mind you will need to do the following before you can make this work from Process Builder:

  1. You need to make an Apex Class and make the method you create Invocable
  2. You will need to configure the Process Builder to use this method and pass in the opportunity that fired your Process.
  3. If you haven't already, you will need to enable tracking in order for the tracking to work. Hope this helps others thanks.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .