Create a Survey Using Flow? Why Not?!

Create a Survey Using Flow? Why Not?!

Last Updated on February 10, 2022 by Rakesh Gupta

Big Idea or Enduring Question:

How do you create a customer-facing survey in Salesforce using out-of-the-box features? 

The survey helps you to drive your business forward by using a survey tool to capture the voices and opinions of the people who matter most to you. Some of the common types of surveys are:

  1. Customer Satisfaction Survey – How satisfied are your customers? This type of survey will allow you to connect easily with your customers and get direct feedback from them.
  2. Net Promoter Score Survey – The Net Promoter Score survey consists of a two-part questionnaire. The first part asks your customers to rate – the rating question – your business, product, or service on a scale of 0 to 10. The second question is a follow-up, open-ended question as to why the specific score was given.
  3. Employee Survey – Employees are the most important asset of any company, so their feedback is important. An online survey is a quick, convenient & cost-saving way to do this.
  4. Product Survey – To make your product the best it can be, it is important to get feedback from your customers. A product feedback survey will provide you with valuable information.
  5. Market Research Survey – The great thing about an online survey is that you can reach a worldwide audience to maximize the impact of your market research and collect a wide range of answers.

Salesforce offers survey features which include 300 responses after that you have to purchase it. Refer Salesforce help article for more information. There are a few apps available on AppExchange for this purpose. In this article, we will create automation that allows the system administrators to create surveys in Salesforce using Salesforce Flow, Site, Visualforce Page, and Lightning Component


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

  • Create a screen with few screen components
  • Automatically stores survey results in a custom object 
  • Open survey to people outside of your Salesforce org
  • How to use Lightning Email Template in an Email Alert  

Business Use Case

Sergio Armendariz is an App Developer at GurukulOnCloud (GoC). He received a requirement to create a survey that can be filled by anyone on this planet without giving them Salesforce access. The survey must contain the following fields:

  1. Name
  2. Email
  3. Rating
    1. Options – 1, 2, 3, 4, 5
  4. Comment 

They also want to send out a thank you email to participants. 

Automation Champion Approach (I-do):

There are a few possible solutions for the above business scenario. However, our purpose, in this blog, is to learn Flow and its advanced/new features. Therefore, we will use Salesforce Flow, Site, Visualforce Page, and Lightning Component to solve the above business requirement 

Before discussing it, let me show you a diagram of a Process Flow at a high level. Please spend a few minutes to go 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 Sergio’s business requirement using Salesforce Flow. We must:

  1. Create a custom object that will be used to store survey responses 
  2. Create a lightning email template
  3. Create an email alert
  4. Salesforce Flow Steps:
    1. Create a screen that will allow users to enter survey responses 
    2. Add a create records element to insert survey response 
    3. Use action to send out email alerts to users
  5. Create a lightning app to render lightning runtime for flow in a visualforce page
  6. Create a visualforce page and embed flow into it
  7. Create a site to open the flow for unauthenticated access

Step 1: Create a Custom Object 

The next step is to create a custom object Survey Result and a few custom fields to store survey responses.  

  1. Click Setup.
  2. In the Object Manager, click Create | Custom Object.
  3. Now create a custom object Survey Result and fields as shown in the screenshot below: 
  4. Click Save.

Step 2: Create a Thank You For Survey Lightning Email Template 

  1. Click App Launcher.
  2. In the Quick Find box, type Email Templates.
  3. Clicks on the New Email template button. 
  4. Name the Lightning Email Template and make sure to store it in the Public Email Templates folder.
  5. Create a template like the following screenshot

Step 3: Create an Email Alert 

  1. Click Setup.
  2. In the Quick Find box, type Email Alerts.
  3. Select Email Alerts, click on the New Email Alert button
  4. Name the Email Alert and click the Tab button. The Unique Name will populate. 
  5. For Object select Survey Result.
  6. For the Email Template chooses Lightning Email Template Thank You Email – Survey
  7. For Recipient Type select Email Field: Email.
  8. Click Save.

Step 4.1: Salesforce Flow – Create a Screen that Allow Users to Fill Survey 

  1. Click Setup.
  2. In the Quick Find box, type Flows.
  3. Select Flows then click on the New Flow.
  4. Select the Screen Flow option and click on Next and configure the flow as follows: 
    1. How do you want to start building: Freeform
  5. We will use the Screen element to capture a Survey response form. Drag and drop a Screen element onto the canvas. And then, follow the steps as shown in the video:

Step 4.2: Salesforce Flow – Add a Record Creates Element to Save Survey Response 

  1. Drag-and-drop the Create Records element onto the Flow designer. 
  2. Enter a name in the Label (Save Response) field; the API Name will auto-populate.
  3. For How Many Records to Create – select One.
  4. For How to Set the Record Fields – select Use separate resources, and literal values.
  5. Select the Survey_Result__c object from the dropdown list.
  6. Set Field Values for the Survey Result
    1. Row 1:
      1. Field: Comment__c
      2. Value: {!Comment}
    2. Click Add Row
    3. Row 2:
      1. Field: Email__c
      2. Value: {!Email.value}
    4. Click Add Row
    5. Row 3:
      1. Field: Name__c
      2. Value: {!Name.firstName} {!Name.lastName}
    6. Click Add Row
    7. Row 3:
      1. Field: Rating__c
      2. Value: {!Rating}
  7. Click Done.

Step 4.3: Salesforce Flow – Call an Acton – Email Alert to Send Out Thank You Email

The next step is to call the Survey – Thank You Email email alert from flow so that when flow fires it triggers the thank you email to survey participants. 

  1. Under Toolbox, select Element
  2. Drag-and-drop Action element onto the Flow designer. 
  3. In the Action box, type Survey – Thank You Email.
  4. Clicks on the Survey – Thank You Email email alert. 
  5. Click Done.

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


  1. Click Save.
  2. Enter Flow Label the API Name will auto-populate.
  3. Click Show Advanced.
  4. How to Run the Flow: User or System Context—Depends on How Flow is Launched
  5. Type: Screen Flow
  6. API Version for Running the Flow: 51
  7. Interview Label: Sirvey {!$Flow.CurrentDateTime}
  8. Click Save.


Step 5: Create a Lightning Application to Render Lightning Runtime for Flow in a Visualforce Page 

Now we will create a Lightning Application that declares a dependency on the lightning:flow component.

  1. Click Setup | Developer Console
  2. Navigate to File | New | Lightning Application 
  3. Enter a Name (VFPageToLC) field, make sure to select the Lightning Out Dependency App checkbox.
  4. Click Submit.
  5. Copy code from GitHub and paste it into your Lightning Application.  
  6. Save your code. 

Step 6: Create a Visualforce Page and Embed Your Flow Into It 

Now we will create a Lightning Application that declares a dependency on the lightning:flow component.

Add the Lightning Components for Visualforce JavaScript library to your Visualforce page using the <apex:includeLightning/> component. In the Visualforce page, reference the dependency app. Then write a JavaScript function that creates the component on the page using $Lightning.createComponent()

  1. Click Setup.
  2. In the Quick Find box, type Visualforce Pages.
  3. Clicks on the New button.
  4. Copy code from GitHub and paste it into your visualforce page 
  5. Click Save.

Step 7: Create a Site to Open Your Flow for Unauthenticated Access

Now we will create a site to open the flow for unauthenticated access. 

  1. Click Setup.
  2. In the Quick Find box, type Sites.
  3. Clicks on the New button.
  4. Fill the details as per the screenshot below: 
  5. Click Save.

Under site, Public Access Settings make sure that guest users have Create access on Survey Result object and Edit on the fields.

Proof of Concept

Now onward, if someone opens the site url and fills the form: 

After successful submission, he/she will receive an email. 

Formative Assessment:

I want to hear from you! 

What did you learn from this post, is it relevant to you, and how will you modify the concepts taught in the post for your own business processes? 

Make a post and tag me on Twitter @automationchamp, using #AutomationChampion.

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

54 thoughts on “Create a Survey Using Flow? Why Not?!

  1. Hello Rakesh sir,

    After learning from your profile, I tried to do if again. Please find the below steps:
    1. Created a custom object with custom fields (non mandatory fields).
    2. Created Email template and saved in public folders.
    3. Created the exact flow as above instruction with email alert.
    4. I have created survey record and included the VF page in it.
    5. Now, record(s) should get inserted upon hitting Next button from the component and an email should float but I ran into the below error, please help.

    Error: insufficient access rights on cross-reference id: 005280000017DV0

  2. receiving error: An unhandled fault has occurred in this flow
    An unhandled fault has occurred while processing the flow. Please contact your system administrator for more information.

    Only on the Site page. When i run from visualforce page it works.

  3. Hi Mr. Rakesh,

    Thank you for this article. This helped me a lot since I am new to the salesforce. I tried all steps given by you but getting below mentioned error. Can you please guide here?

    SObjectRowId = {!Save_Response} (a0E5g000000p3BYEAY)
    Error Occurred: insufficient access rights on cross-reference id
    Salesforce Error ID: 2076258280-33057 (261907581)

  4. Hi Rakesh !

    Thanks for the POC and this is really helpful.
    I just have one question regarding the guest users who fill the survey, There can be a use case that the survey is 10 pages long and user may want to take a break or partial save the responses.

    How can we identify that the existing user who had partial responses set is open the survey link ? Is there a unique key associated to each guest user that we can leverage to show them a different screen with prepopulated responses.

    Any insights will be helpful.

    Thanks !

  5. Can you provide details how to update using Lightning flow? Specifically how do you display a lightning flow on the VF page since the page displays in Classic?

  6. Hi Rakesh,

    First of all thank you for posting out such a great articles around flows.

    However, i have a question. I want my flow to get associated with a parent record . How can i associate it when the survey gets completed,

    1. Hey Rabindranath, thanks for the great comment. Hearing stuff like this makes my day.

      Here is my suggestion – if you want to use email address to find parent record:

      1. Create a process (using Process Builder) on Survey record creation
      2. Which will fire a Flow
      3. Where you have to manage all logic to associate the survey record with its parent

  7. hi rakesh, this is awsome,

    I am unable to relate the surveys to the right case number( could you please help with this this is very IMP)

    also when i tested i clicked on NO when i started the survey it is not redirecting me to the THANK-YOU SCREEN when i select NO

    1. Thanks for your kind words!

      Without looking into your Flow, it is tough to comment. Please check your Record Create/Update action (which update Survey record to Case) and make sure that you are passing record ID correctly. Use Screen element to debug it.

      Please let me know how it goes.

  8. It would be really helpful, if you can give some example to store the id from the URL and use this in the flow. Your consideration in this regards would be highly appreciated!!

  9. Hi Rakesh,
    I have requirement where,
    1. When Case is Resolved, Customer will get an email with a link to fill a survey
    2. When user will fill the Survey (via Public site), the Case will be marked to Closed in Salesforce.

    The point no-1 I have achived, but for the point number-2 I am not getting How Salesforce recognize that the Survey is filled for the Resolved Case and will mark it to Close. There is anyway to do that. On thing I can do that is I can pas the Case Id in the Public site URL, after how I can play with that, not able to get any thought. Please help me out here.


    1. For pint number 2 either you can pass CaseID or contact email and save the data in survey object.

      Later on use Record update element to find the correct case record based on CaseID or email then close it

      1. if I pass the caseid in public site URL, will it open the flow??(I will try this my self),
        But if suppose flow will get open, how I can map this caseid from the browser URL to the flow, how this caseid will be retained/fetched during flow interview

        1. Store the value into a variable then store it in Survey record.

          You may need to create another Automation on Survey. As soon as Record gets created, find the case with matching ID and close it.

  10. Dear Rakesh,

    I was wondering, if someone would reply again on that email that got sent, who will receive that email then ?
    Can you assign that in salesforce ?

  11. also another thing, my flow in salesforce creates a new lead with the correct record type, but when im using my website it doenst create any record in salesforce.
    i did the following so far setup ->sites-> registerd a new site like you explained ->public access settings->object settings->lead->object permisions read and create->field permissions-> everything picked (just to check it’s not there where i made a mistake)
    also ticked the correct record type with the correct page layout.

    and created the visual force page with the correct flow name (in preview the flow appears)
    Is there also another setting im missing ?

    1. Make sure that you have setup Field -level security correctly for Guest user profile and grant Visualforce page access to Guest User profile.

      1. hey thanks, i noticed that owd in my sandbox for leads was on private, i put it on public, read, write , transfer and now my form is filling salesforce

  12. Dear Sir Gupta,

    First thank you for this amazing blog, i really would like to learn flow and try everyday now to do one tutorial. Still im really a beginner.
    Now currently i’m making for the first time a flow for a company.
    For some reason the email i would like to send after record creation doesnt arrive.
    I followed your workflow rules and i think i did the same.
    My flow creates a certain record type in the lead object, do i have to specify another criteria now for sendig an email ?

    Also isnt process builder a better solution for sending an email alert ?

    Or has this something to do with the order of execution ?

    Oof i have so much to learn 🙂

    1. You can either use Flow or Process Builder to send an email. If you are using Sandbox then make sure that Email Deliverability is set to All emails.

    1. Thank you! I am glad you liked it 🙂

      Good question, as we have the email address stored in survey record.

      To related contact and survey record, try something like this

      1. Create a lookup of Contact on Survey object
      2. Once survey record gets created, trigger another process and Flow
      3. Flow will identify matching contact based on the email address
      4. Once you have contact ID, update the survey record

  13. Hi Rakesh:
    For the Screen #3, I clicked on Add Field and Output (Display Text); However, Display Text does not let me write Thank you for your Participation. Because, it only has Unique Name (means no spaces between words). Please let me know where am I going wrong. Thanks

  14. Hi Rakesh,

    can you share how can I pass value of the case Id from the link that will be sent to customer after closing the case?

  15. I just ought to tell you which you have written an exceptional and distinctive post that I really enjoyed reading. Im fascinated by how nicely you laid out your material and presented your views. Thank you. aeedaeafdada

  16. One thing to think about is the finishLocation for your flow. In your example, when clicking finish, I am brought to a new survey, essentially starting the flow over again. I have created a VF page that is a simple javascript function to close the window; from there I embed the survey flow in its own VF page while setting the finishLocation to my windowclose visualforce page. Now when they click Finish, rather that the start of the Flow, it closes the window (or whatever URL/VF page you set as the finishLocation).

    1. Thanks Dan to point it out. Yes you can close window or divert user to some page as soon as they complete the survey. I created this for just to the power of Visual workflow.

Leave a Reply

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