0

I need to send an email notification to the record owner and manager once the opportunity is closed-won.

adding only owner email works fine

adding only manager email works fine

But if I add both together with coma, {!$Record.Owner.Email},{!$Record.Engagement_Manager__r.Email} I'm getting error.

what is the correct way to add it?

Prithivi
  • 1
  • 1
  • 1

4 Answers4

0

You can try creating a Formula Resource in your flow like this but, in your case, using $Record.Owner.Email and $Record.Engagement_Manager__r.Email:

Resource Example

Then, you can use this Resource in your Email Action:

Email Action

0

Try the below code and let me know if it works.

global class SendPurchaseOrderEmail {
    WebService static void sendEmail(String poId) {
        List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();
        
        String theTemplate = [SELECT Id FROM EmailTemplate WHERE DeveloperName = 'Purchase_Order_With_Items'].Id;
        User theUser = [SELECT Id FROM User WHERE Name = 'user name goes here'];

        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        
        mail.setSaveAsActivity(false);
        mail.setTemplateId(theTemplate);
        mail.setWhatId(poId);
        mail.setTargetObjectId(theUser.Id);
        mail.setToAddresses(new String[] { 'TestUser@salesforce.com' ,'abc@test.com'});  //add other emails here.
        emails.add(mail);
        
        Messaging.sendEmail(emails);      
     
    }    
}

Please refer below link for more details. https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_sendemail.htm

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
0

This is because you have to pass a direct email address there. Instead of that, you can create a collection variable, store the emails into it, then pass that variable to email addresses (collection) field.

Note: you can only store upto 5 emails into that colllection variable at a time.

kiuQ
  • 931
  • 14
Subhrut Taori
  • 27
  • 1
  • 2
  • 11
0

Hi For that you can simply add collection Variable. For that variable assign multiple values to it. So that you can send email to both record owner as well as manager.

From New Resource Select the Variable and click Allow Multiple Values and Data-type as text.

Then by using Assignment. Add the following email Address to it Please refer the below image.

I hope you have got the solution

Thanks

Vicky
  • 1
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 21 '23 at 17:21