Notify Opportunity Owner when a Survey Response is Received

Advertisements

Big Idea or Enduring Question:

  • How do you notify the opportunity owner when a customer submits a survey (post-sales) response? 

Objectives:

After reading this blog, you’ll be able to: 

  • Understand SurveyQuestionScore, SurveyInvittaion objects 
  • Use flow to notify the opportunity owner when a post-sales survey response is received 
  • Find out if a survey is associated with an account, case, or other objects 
  • Use send email core action to notify the opportunity owner
  • and much more

Business Use case

Olivia Rodrigo is working as a System Administrator at Gurukul on Cloud (GoC)She is in the process of implementing Survey at GoC. Last week, She received the following request from the Client Success Manager: 

  • Whenever a post-sales survey response is received, send an email to the opportunity owner.

Prerequisite

Please go through this article first and make sure to create it:

  1. Send Salesforce Survey Without Code

Automation Champion Approach (I-do):

Out of the box, Salesforce doesn’t provide a way to notify related record owners when a survey response is received. Such notifications are beneficial to take action to make sure that the customer is happy. This article will help you to learn how you can use record-triggered flow to notify the opportunity owner when a response is received.

You can further customize the flow to notify the owner only when the survey score or Net Promoter Score (NPS) falls below your company-defined standard.

While this can be solved using various automation tools like Apex Trigger, or Flow, we will use After-save Record-Triggered Flow. Check out this article to understand why we are using after-save record-triggered flow for this scenario.

Let’s take a pause here, and familiarize ourselves with the SurveySubject and SurveyInvitation objects in Salesforce including the data model. 

Object Name Details
SurveySubject It represents a relationship between a survey and another object, such as an account or a case.
SurveyInvitation It represents the invitation sent to a participant to complete the survey.

Before discussing the solution, let me show you a diagram of a Process Flow at a high level. Please spend a few minutes going through the following Flow diagram and understand it.

Let’s begin building this automation process.

Guided Practice (We-do):

There are 7 steps to solve Olivia’s business requirement using After-Save Record-Triggered Flow. We must:

  1. Define Flow properties for record-triggered flow
  2. Add a decision element to check the survey response status 
  3. Add a get records element to find the SurveySubject
  4. Add a decision element to check if the SurveySubject is associated with an opportunity or other object 
  5. Add a get element to find opportunity details 
  6. Add a Text Template to construct the email body
  7. Add send email action  – to notify the opportunity owner 

Step 1: Define Flow Properties

  1. Click Setup.
  2. In the Quick Find box, type Flows.
  3. Select Flows then click on the New Flow.
  4. Select the Record-Triggered Flow option, click on Create and configure the flow as follows:
    1. Object: Survey Response
    2. Trigger the Flow When: A record is created or updated
    3. Set Entry Criteria
      1. Condition Requirements: None
    4. Optimize the Flow For Action and Related Records
  5. Click Done.

Step 2: Using Decision Element to Check if the Survey Response Status Equals Completed

Now we will use the Decision element to check if the survey response equals completed to make sure that the participant has completed the survey.

  1. On Flow Designer, click on the +icon and select the Decision element.
  2. Enter a name in the Label field; the API Name will auto-populate.
  3. Under Outcome Details, enter the Label the API Name will auto-populate.
  4. Condition Requirements to Execute Outcome: All Conditions Are Met (AND)
    1. Row 1:
      1. Resource: {!$Record.Status}
      2. Operator: Equals
      3. Value: Completed
  5. When to Execute Outcome: If Only if the record that triggered the flow to run is updated to meet the condition requirements
  6. Click Done.

Step 3: Adding a Get Record Element to Find the Survey Subject related to Survey Invitation 

The next step is to use the Get Records element to find the survey subject related to the survey invitation.

  1. On Flow Designer, below the Completed node, click on the +icon and select the Get Records element.
  2. Enter a name in the Label field; the API Name will auto-populate.
  3. Select the Survey Subject object from the dropdown list.
  4. Select All Conditions Are Met (AND)
  5. Set Filter Conditions
    1. Row 1:
      1. Field: SurveyInvitationId
      2. Operator: Equals
      3. Value: {!$Record.InvitationId}
  6. How Many Records to Store:
    1. select Only the first record
  7. How to Store Record Data:
    1. Choose the option to Automatically store all fields
  8. Click Done.

Step 4: Using Decision Element to Check If the SurveySubject is Associated with an Opportunity or Other Object

Now we will use the Decision element to check if the survey subject is associated with an opportunity or any other object. 

  1. On Flow Designer, click on the +icon and select the Decision element.
  2. Enter a name in the Label field; the API Name will auto-populate.
  3. Under Outcome Details, enter the Label the API Name will auto-populate.
  4. Condition Requirements to Execute OutcomeAll Conditions Are Met (AND)
    1. Row 1:
      1. Resource: {!Find_SurveySubject.SubjectEntityType}
      2. Operator: Equals 
      3. Value: Opportunity
  5. When to Execute Outcome: If the condition requirements are met.
  6. Click Done.

Step 5: Adding a Get Record Element to Find the Opportunity Record Details 

The next step is to use the Get Records element to find the opportunity record details.

  1. On Flow Designer, below the Yes node, click on the +icon and select the Get Records element.
  2. Enter a name in the Label field; the API Name will auto-populate.
  3. Select the Opportunity object from the dropdown list.
  4. Select All Conditions Are Met (AND)
  5. Set Filter Conditions
    1. Row 1:
      1. Field: Id
      2. Operator: Equals
      3. Value: {!Find_SurveySubject.SubjectId}
  6. How Many Records to Store:
    1. select Only the first record
  7. How to Store Record Data:
    1. Choose the option to Automatically store all fields
  8. Click Done.

Step 6: Add a Text Template to Construct Email Body 

 Now we’ll create an email template using the Text Template. The text template allowed you to specify the multi-line messages. It also allows you to use HTML code.

  1. Under Toolbox, select Manager, then click New Resource to create a text template. 
  2. Input the following information: 
    1. Resource Type: Text Template
    2. API Name: textT_MessageBody
    3. Select View as Rich Text
    4. Body 
      1. A Survey response is received for the opportunity https://myautomationchampion-dev-ed.lightning.force.com/{!Find_SurveySubject.SubjectId}.
  3. Click Done.

Step 7: Add Send Email Action to Notify the Opportunity Owner

Now we will use the Send Email core action to send out an e-mail to the opportunity owner. 

  1. On Flow Designer, click on the +icon and select the Action element.
  2. Search and select the Send Email from the dropdown menu
  3. Enter a name in the Label field; the API Name will auto-populate.
  4. Set Input Values
    1. Body: {!textT_MessageBody}
    2. Subject: Survey Response – {!Find_opportunity.Name}
    3. Email Addresses (comma-separated): {!Find_opportunity.Owner.Email}
    4. Rich-Text-Formatted Body: {!$GlobalConstant.True}
  5. Click Done.


In the end, Olivia’s Flow will look like the following screenshot:


Once everything looks good, perform the steps below: 

  1. Click Save.
  2. Enter Flow Label the API Name will auto-populate.
  3. Click Show Advanced.
  4. API Version for Running the Flow: 54
  5. Interview Label: Lower Survey Response – Notify Opportunity Owner {!$Flow.CurrentDateTime}
  6. Click Save


Almost there! Once everything looks good, click the Activate button.  

Proof of Concept

From now onwards, once a survey response is received, then the record-triggered flow will automatically trigger and notify the opportunity owner. 

  1.  Completed Survey Response.
  2. Email notifications to opportunity owner.

Formative Assessment:

I want to hear from you!

What is one thing you learned from this post? How do you envision applying this new knowledge in the real world? Feel free to share in the comments below.

Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!
Preferred Timing(required)

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Automation Champion

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version
%%footer%%