The survey is very important to grow your business and get feedback from the customer on your product or services time-to-time to improve it. Now if your customer says to create a Survey in Salesforce and they want to show one question on every screen and they also want anyone can access this feedback without login into Salesforce, and as soon as they are done with feedback all data should be saved into some object. Now first thing comes up in your mind is a Visualforce page, but no we can handle this type of situation with Visual workflow.
Business Use Case
Universal container management wants to create a simple survey with fields (Name, Email Address, Rating, and Comment) form and they want a way to host this form so anyone can access it without login into Salesforce.
Solution for the above business use case
First of all we have to create a Survey Object with below-mentioned fields so we can save customer’s feedback
Object Name | Data Type | Display Format |
Survey | Number | S-{0000} |
Now Create custom fields on Survey object as per below table
Field Name | Data Type |
Comment | Text Area(255) |
Email Address Send | |
Name | Text(100) |
Rating | Text(45) |
Now we will create a simple survey form, to do this follow the below instructions
- Click on Name | Setup | App Setup | Create | Workflows & Approvals | Flows
- Click on New Flow, it will open flow canvas for you
- Drag and drop a Screen #1 ( Give the name Ready for survey) on window, add field Drop-down (Name – Ready For Survey) with Value Yes/No as shown in below screen shot
- Now we will add another screen #4 ( Give the name survey) to create a survey. Drag and drop a Screen from palette Add textbox ( Click on Add a field tab to ad field) to save Name, make it required field and fill the details as shown in below screen shot
- Like wise you can add Email address field on the same screen use Text-box type field only, as below in below screen shot
- Now add another field called as Rating data Type (Radio Button) make it required field, select choice value data type as number (Enter 1, 2,3 ,4 and 5 as choice) , same as below screen shot
- Likewise you can add Comment box (Data Type: – Text Area long) make it required field, finally, it will look like below screenshot
- Now we will create record on Survey object based on data field on Survey form. To do that drag and drop Record Create Lookup i.e Screen #5 from palette, enter the Name and map field according to your choice in our case you can map survey field with Screen#4 input field as shown in below screen shot
- Now we will create Thanks Screen #3 , to do that drag and drop screen into canvas, navigate to Add a field tab move to Output section and use output text and enter some message as shown in below screen shot
- Now add decision into your canvas, to make sure if user doesn’t want to participate in the survey redirect them to thanks, screen. For this, you have to add two outcomes (One for Yes and one for No) as shown in below screen shot
Finally, Our flow will look like below screen shot, you can also add thanks, message after completion of Survey as I did
Note :- Make sure you set Screen 1 as start point and activate your flow.
You can use this flow within Salesforce very easily. To do that create some custom button and call this flow, If you don’t know how to call flow from custom button you can take help from my old blog (Auto select automatically follow records that I create checkbox). If you want to fire survey on Opportunity closer as your organization wants to save Sales rep feedback that will help in the future deal, you can also do that by using Apex code.
Creating a Visaulforce page
As You can’t grant flow access to the unauthenticated user, so we will use Visualforce page and then host it to Force.com site. Wait I will use only 2 tags to create the VF page. Create on Visualforce page with Name Flow and paste below code and replace word survey with your flow name (I saved my flow with name Survey)
Host Survey on Force.com site
Now next target is the host this form on force.com site so anyone can use this survey form. Do to this follows the path
- Name | Setup | App Setup | Develop | Sites
- If sites are not enabled for your organization, it will look like below screenshot register one for your organization
- Now add Visualforce page under Default Web Address, Active Site Home Page as shown in below screen shot
- Under site, public access settings make sure guest user have created access on Survey object and edit on fields that we are using to create a record in our flow.
- To do that Click on public access settings | Object Settings | Survey object and grant create access on object and edit on fields
Create workflow to send thank you message
The final target is to send thank you message to each participant, for this, we will use, workflow. To create a workflow rule follow the path
- Name | Setup | App Setup | Create | Workflow & Approvals | Workflow Rules
- Click on New Rule button
- Enter entry criteria field Email address send not equals to null
- Add Intimidate action Email alert, you can add your email template and from Recipient, Type drop down select Email field and select Email address send field as shown in below screen shot
It’s time to test this feature
- Run your flow, In the very first screen, it will ask you, if you are ready? Select yes and click next on Survey Screen1as shown in below screen shot
- In the second screen fill the form correctly, mainly use email address proper format (Abc@tets.com), If the email address is correct you will get thank you email and click on next. You can take help from below screen shot
- In the last screen it will show thank you message, click on Finish button then the only survey will complete, as shown in below screen shot
- Record get created in Salesforce, below is the snapshot for your reference
- Thank you email screen print, it will only come if you use correct email address
Note: – You can try my survey form by clicking on “My Survey Form”
45 thoughts on “Survey Powered by Visual Workflow”
Rabindranath Behera
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,
Rakesh Gupta
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
Pingback: How to Include an Unsubscribe Link | Sunshine and Other Unhandled Exceptions
Pingback: How to Create an Unsubscribe Link, Revised | Sunshine and Other Unhandled Exceptions
SARTHAK GARG
How to do this functionality with vf page only.
Rakesh Gupta
Sorry, I didn’t get you.
Kajal
When I select NO from drop down list,It is redirecting me to create Survey Screen instead of THANK-YOU Screen. Please help!
Md Sarfaraz
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
Rakesh Gupta
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.
Md Sarfaraz
It would be difficult to put the complete screen shot. here is login access for the dev org.
Rakesh Gupta
Sorry, I removed your credentials. Please email me at infoatautomationchampiondotcom
Nitin
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!!
Rakesh Gupta
Check out this article https://automationchampion.com/2014/08/09/click-and-join-chatter-group-3/
Nitin
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.
Thanks,
Nitin
Rakesh Gupta
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
Nitin
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
Rakesh Gupta
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.
Anindya~~
wow
eiyu
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 ?
eiyu
also another thing, my flow in salesforce creates a new lead with the correct record type, but when im using my site.com 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 ?
Rakesh Gupta
Make sure that you have setup Field -level security correctly for Guest user profile and grant Visualforce page access to Guest User profile.
eiyu
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
eiyu
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 🙂
Rakesh Gupta
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.
Fraidy
hi, thank you for this. How can I relate the response to the matching contact in salesforce?
Rakesh Gupta
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
Fraidy
Thank you for your reply, can you please clarify how to do #3? How can I create a flow that will return the Contact ID?
Rakesh Gupta
Use a record lookup element to find the contact(s) based on email address 🙂
Munira Majmundar
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
Rakesh Gupta
Please refer the below URL
https://rakeshistom.files.wordpress.com/2016/09/screen-shot-2016-09-28-at-5-37-28-pm.png
Munira Majmundar
Thanks Rakesh, got it! Did not know I needed to write ‘Thank you for your participation’ inside the square 🙂
Munira Majmundar
Rakesh… great post. On the first screen, https://rakeshistom.files.wordpress.com/2014/04/ready-for-survey.png
There is a sentence, Are you ready for survey?
How did you get that sentence there?
I can see how you got ‘Ready for Survey’… but not Are you ready for survey?
Rakesh Gupta
It is nothing but an extra “Display Text”
Jayson Faderanga
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?
Rakesh Gupta
Where you want to pass the CaseId ? Can you please explain
Pingback: Getting Started with Visual Workflow – Part 1 (Launch a Flow using Lightning App) « Rakesh Gupta's Blog
Rakesh Gupta
Make sure that you have activated the flow, else you will get Authorization Required error
Johnc941
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
Pingback: Rakesh Gupta’s Salesforce Newsletter of the Week – 03rd May 2014 « Rakesh Gupta's Blog
Pingback: Rakesh Gupta’s Salesforce Newsletter of the Week – 05th April 2014 « Rakesh Gupta's Blog
Dan
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).
Rakesh Gupta
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.
Brian Makas
How can you divert user? Can VisualForce read the “finished” status of the Flow?
Rakesh Gupta
Either you can use Visualforce page (Finishlocation) or if you are using custom button/link to call flow so use “returl”
Rakesh Gupta
You can also use “finishLocation” in VF page