Send Salesforce Survey Without Code

Send Salesforce Survey Without Code

Last Updated on May 8, 2022 by Rakesh Gupta

Big Idea or Enduring Question:

  • How do you send survey invitations using flow? 

Objectives:

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

  • Understand the salesforce survey data model
  • Use flow to send survey invitations to a contact 
  • Associate survey invitations to Survey Invitations and Response related list 
  • 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 an opportunity is closed-won, send a survey invitation to the primary contact role of the opportunity. 

Prerequisite

Make sure that Salesforce Survey is enabled and correctly set up. Second, create a survey (Customer Satisfaction) similar to the following screenshot:

Automation Champion Approach (I-do):

First of all, let’s understand different approaches to sending survey invitations. 

Do You need a Flow to Send Survey Invitations? 

The answer is no, and we don’t need a flow or apex code to send the survey invitation anymore. Unless you hit a roadblock that we will discuss in this article. Use Survey Invitation Rules to trigger a survey invitation based on criteria without creating a flow.

What is Survey Invitation Rule? 

Survey Invitation Rules allow you to send rule-based surveys when a record is created or updated for a SurveySubject supported object. Add a customer engagement context to the rule to collect information about the groups that are targeted.

The following survey invitation rule triggers a survey invitation when a case gets closed.

Use Case of Using Flow to Send Survey Invitation 

But Survey Invitation Rules come with limitations, for example:

  1. Send a survey invitation to key contact when an order has been delivered
  2. Send a survey invitation to the primary contact role when an opportunity is closed won
  3. Define survey invitation expiration date
  4. and much more

You can overcome by using Flow or Apex code.

Understand Salesforce Survey Data Model

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.
Source – Salesforce help

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.

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 validate opportunity stage equals closed won
  3. Add a get records element to find the primary contact role on opportunity 
  4. Add a decision element to check if the primary contact role found 
  5. Add a text variable to store the primary contact record Id
  6. Add a text variable to store the opportunity record Id
  7. Add core action send surveys – to send out a survey invitation

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: Opportunity
    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 Opportunity Stage Euqals to Closed Won

Now we will use the Decision element to check if the opportunity is marked as closed-won. 

  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.StageName}
      2. Operator: Equals
      3. Value: Closed Won
  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 Primary Contact Role on Opportunity. 

The next step is to use the Get Records element to find the primary contact role on the opportunity. 

  1. On Flow Designer, below the Closed Won 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 Contact Role object from the dropdown list.
  4. Select All Conditions Are Met (AND)
  5. Set Filter Conditions
    1. Row 1:
      1. Field: IsPrimary
      2. Operator: Equals
      3. Value: {!$GlobalConstant.True}
    2. Click Add Condition
    3. Row 1:
      1. Field: OpportunityId
      2. Operator: Equals
      3. Value: {!$Record.Id}
  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 Primary Contact Role Found or Not 

Now we will use the Decision element to check the Record Variable from step 3 to find if it primary contact role or not. 

  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: {!Get_Primary_Contact}
      2. Operator: Is Null 
      3. Value: {!$GlobalConstant.False}
  5. When to Execute Outcome: If the condition requirements are met.
  6. Click Done.

Step 5: Create a Text Variable to Store the Primary Contact Record Id

  1. Under Toolbox, select Manager, then click New Resource to store the primary contact role Id. 
  2. Input the following information: 
    1. Resource Type: Variable
    2. API Name: varT_ContactId
    3. Data Type: Text
    4. Default Value: {!Get_Primary_Contact.ContactId}
    5. Check Available for Input
    6. Check Available for Output
  3. Click Done.

Step 6: Create a Text Variable to Store the Opportunity Record Id

The purpose of creating a variable to store opportunity id is, that the Survey Subject input field for Send Survey action doesn’t allow us to refer {!Record}. 

  1. Under Toolbox, select Manager, then click New Resource to store the opportunity record Id. 
  2. Input the following information: 
    1. Resource Type: Variable
    2. API Name: varT_RecordId
    3. Data Type: Text
    4. Default Value: {!Record.Id}
    5. Check Available for Input
    6. Check Available for Output
  3. Click Done.

Step 7: Add Send Survey Core Action to Send out a Survey Invitation

Now we will use the Send Survey static action to send out a survey invitation. 

  1. On Flow Designer, below the Yes node, click on the +icon and select the Action element.
  2. Search and select the customer_satisfaction survey from the dropdown menu
  3. Enter a name in the Label field; the API Name will auto-populate.
  4. Set Input Values
    1. Survey Subecjt: {!VarT_RecordId}
    2. Recipient Type: Contact
    3. Recipient: {!varT_ContactId}
    4. Unique Link: Checked
    5. Don’t require authentication: Checked
    6. Invitation expires in days: 30
  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: Send Salesforce Survey Without Code{!$Flow.CurrentDateTime}
  6. Click Save

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

Proof of Concept

From now onwards, a survey invitation will be automatically sent out to the primary contact whenever an opportunity is updated as Closed Won. 

  1. Now we will try to update the Opportunity “1832” Stage to Closed Won.
    1. our automation automatically populates Survey Invitation and Response related list and also sent out survey invitations to the primary contact.
  2. Survey Invitation Email sent by Salesforce
  3. Salesforce Survey Sample

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!

Leave a Reply

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