• +91 9311 5511 17
  • info@websharpmarketing.com
Web Sharp Marketing Web Sharp Marketing
Get A Quote
  • Home
  • About Us
  • Our Services
    • Full Stack Development
    • Salesforce Training
    • Salesforce Solutions
    • Data Migration and Processing
    • Code Review, QA and Support
    • Website Designing
  • Blog
  • Contact Us
  • February 27, 2024
  • WSM
  • 0 Comments
  • 443 Views
  • 0 Likes
  • Admin, Flows

Sending Automated Emails to All Related Contact Roles When an Opportunity is Won

For users who would like for all of the Contact Roles to be automatically emailed after a related Opportunity is Closed Won, this can be accomplished by creating a Record-Triggered Flow. If users forget to add a Contact Role, this Flow will not send any emails and still allow the Opportunity to be closed.

Resolution

Pre-Work: Create Classic Email Template

  1. Click the gear icon on the top right corner of the Salesforce screen
  2. Select Setup
  3. In the Quick Find box, search for Classic Email Templates and open it
  4. Click New Template
  5. For this example, select the Custom option
  6. Click Next
  7. Check the box for Available For User
  8. Provide it with an Email Template Name like Closed Won Opportunity as an example
  9. Click Next
  10. Paste these merge fields into the Subject field as an example
    • {!Opportunity.Name} {!Opportunity.StageName}
  11. Paste these merge fields into the HTML Body field as an example
    • Opportunity Name:{!Opportunity.Name}
      Stage: {!Opportunity.StageName}
      Close Date: {!Opportunity.CloseDate}
      Amount: {!Opportunity.Amount}
      Link: {!Opportunity.Link}
  12. Click Next
  13. Click Copy text from HTML version
  14. Click Save

Pre-Work: Create Email Alert

  1. In the Quick Find box in Setup, search for Email Alert and open it
  2. Click New Email Alert
  3. Provide it with a Description like Email Alert for Closed Won Opportunity Flow as an example
  4. Select Opportunity as the Object
  5. Select Closed Won Opportunity as the Email Template
  6. Select Related Contact as the Recipient Type
  7. Move Related Contact: Contact from the Available Recipients column to the Selected Recipients column
  8. Click Save

Create a New Flow

  1. In the Quick Find box in Setup, search for Flows and open it
  2. Click New Flow 
  3. Select Record-Triggered Flow and click Next
  4. Click Auto-Layout

Tell the Flow When to Start

  1. Click Start so a box appears
  2. Click Edit to the right of Trigger
  3. Select to Trigger the Flow when A record is created or updated
  4. Select to Run the Flow After the record is Saved
  5. Click Done
  6. Click +Choose Object
  7. Select Opportunity as the Object
  8. Set the Condition Requirements to All Conditions Are Met (AND)
    • Set the Field to StageName
    • Set Operator to Equals
    • Set Value to Closed Won
  9. Set When to Run the Flow for Updated Records to Only when a record is updated to meet the condition requirements
  10. Click Done

Get the Contact Role ID Information From the Opportunity

  1. Click the + icon between Start and End
  2. Select Get Record
  3. Provide a Label like curOpportunityContactRole as an example
  4. Select Opportunity Contact Role as the Object
  5. Set the Condition Requirements to All Conditions Are Met (AND)
    • Set the Field to OpportunityId
    • Set Operator to Equals
    • Set Value to $Record Opportunity.ID
  6. Set the Sort Order to Not Sorted
  7. For How Many Records to Store, select All records
  8. For How to Store Record Data, select Choose fields and assign variables (advanced)
  9. Click in the Field in the Select Variables to Store Opportunity Contact Role Fields section
  10. Click + New Resource
    • Set Resource Type as Variable
    • Provide it with an API Name like colContactRole as an example
    • Set the Data Type as Record
    • Set the Object as Opportunity Contact Role
    • Click the checkboxes for Available for Input, Available for Output and Allow multiple values (collection)
    • Click Done. 
  11. In the Select Opportunity Contact Role Fields to Store in Variable, the first Field is set to ID automatically
  12. Set the second Field to Contact Id
  13. Click Done

Add a Decision to Determine the Flows Actions

  1. Click the + icon under curOpportunityContactRole
  2. Select Decision
  3. Provide it with a Label like Contact Roles? as an example
  4. In the New Outcome section, provide it with a Label like Yes as an example
  5. Set the Condition Requirements to Execute Outcome to All Conditions Are Met (AND)
    1. Set the Resource field to the colContactRole variable you just created
    2. Set the Operator to Is Null
    3. Set the Value to $GlobalConstant.False
  6. For When to Execute Outcome, select If the condition requirements are met
  7. Click Default Outcome
  8. Provide it with a Label like No as an example
  9. Click Done

End Flow if No Contact Role(s) Found

  1. Click the + icon below No
  2. Select End

Create a Loop Element to Get All Related Contacts if Contact Role(s) Found

  1. Click the + icon below Yes
  2. Select Loop
  3. Provide it with a Label like loopContactRoles as an example
  4. Select colContactRole as the Collection Variable
  5. Select First item to last item as the Direction
  6. Click Done

Create Get Records Element Within Loop

  1. Click the + icon below For Each
  2. Select Get Records
  3. Provide it with a Label like getContact as an example
  4. Select Contact as the Object
  5. For the Condition Requirements, select All Conditions Are Met (AND)
    1. Set Field to Contact Id
    2. Set Operator to Equals
    3. Set Value to Current item from Loop>Contact Id>Contact Id
  6. Select Not Sorted as the Sort Order
  7. Select Only the first record for How Many Records to Store
  8. Select Choose fields and assign variables (advanced) for How to Store Record Data
  9. in the Select Variables to Store Contact Fields section
    1. Set Field to Email
    2. Click in the Variable field and click +New Resource
    3. Select Variable as the Resource Type
    4. Provide an API Name like varEmail as an example
    5. Select Text as Data Type
    6. Check the checkboxes for Available for input and Available for output
    7. Click Done
  10. Click Done

Tell the Flow to Send Email to The Contact in The Loop

  1. Click the + icon below getContact
  2. Select Action
  3. Search for then select Closed Won Opportunity in the Action search bar
  4. Provide a Label like Send Email as an example
  5. Select Record Opportunity>Opportunity Id
  6. Click Done
  7. Click Save
  8. Provide it with a Flow Label like Email All Contact Roles When Opportunity Closed Won
  9. Click Activate

 

Resource: Knowledge Article Number 000390005

Prev PostTestSetUp method in apex test classes
Next PostHow to Invoke a Flow from a Lightning Web Component
Related Posts
  • How to Invoke a Flow from a Lightning Web Component March 5, 2024
  • Salesforce Data Migration with DataLoader or Data Import Wizard January 29, 2024

Leave a Comment Cancel Comment

Your email address will not be published. Required fields are marked *

Recent Posts

  • How to get your work history report by PF
  • How Salesforce Delivers Exceptional Service Using Service Cloud
  • How to Calculate and Improve Customer Retention Rate
  • How to Invoke a Flow from a Lightning Web Component
  • Sending Automated Emails to All Related Contact Roles When an Opportunity is Won

Recent Comments

No comments to show.

Popular Posts

March 20, 2024 / Marketing, Salesforce
How to Calculate and Improve Customer Retention Rate

Tags

@isTest @testsetup Admin Administrator Apex Branding Corporate CRR Customers Data Import Wizard Data Loader Data Migration Designing flow JavaScript Lightning Web Component lwc Marketing Mobile Apps Salesforce salesforce developer Test Class test class code coverage unit test Validation Rules Website

Categories

  • Admin
  • Apex
  • Aura Component
  • Development
  • Facts
  • Flows
  • LWC
  • Marketing
  • Mobile Apps
  • Networking
  • Salesforce
  • Service Cloud
  • Social Media
  • Trailhead
  • Web Design

WSM Technosoft’s offering enables clients to quickly augment their Salesforce Consultant teams through product development and support resources located in our development centers. Based upon project’s requirements, WSM Technosoft’s Team can either co-locate at client at site or work from our development center in India.

Our Services

  • Website Designing
  • Salesforce Solutions
  • Salesforce Training
  • Data Migration and Processing
  • Code Review, QA and Support

Recent Articles

  • How to get your work history report

    Aug 21, 2024

  • How Salesforce Delivers Exceptional

    Mar 20, 2024

Useful Links

  • Home
  • Portfolio
  • Contacts
  • Services
  • FAQ
  • About Us
  • Services
  • Blog
  • About Us
  • Contacts
info@websharpmarketing.com
+91 9311 5511 17 Call Us Now
2nd Floor, Devasthali - Plot no. 42/5, Block – A, Sector – 62, Noida, UP - 281203
© WSM Technosoft, 2014–2024. All rights reserved