Technically Salesforce Flow is known as a business ‘workflow wizard’ or simply a sequential set of screens that can be used to complete or assist smartly on a business process or workflow. But here at Algoworks we define it in one word- awesome.
In my previous blog on Salesforce Flow, we had an overview of what Salesforce Flow is, what is the difference between Salesforce.com Flow and Workflow, how to create trigger Flow and how to use Flows to send an E-mail? In this blog I shall be talking about the one thing I assured you I would cover in my next blog – How to create surveys and the technical and logical aspects of it.
In its early versions, Salesforce was not flexible enough to allow developers to create complete business applications. It was mainly used as an ordinary sales tracking and analysis software. Its cloud capabilities and its ability to integrate with any type of database or legacy system were the main USPs, however user was required have to login and maneuver through a very complex Salesforce UI for such simplest of tasks. Though one can argue that Salesforce was anyways not meant to handle simple tasks, it did not yet cope up in the UI department. To make their business process more user-friendly and the data entry process faster, developers used to create separate web based apps to display and update Salesforce data.
However with the launch of Visualforce and Salesforce site.com, developers can now create complete Salesforce based web apps. Salesforce Flow is one of the best feature for Visualforce users.
Salesforce visual workflow is specifically great to create survey pages. But before we dwell further into its processes, here I am assuming that you have a decent idea about what is Salesforce and Salesforce Visualforce.
So without waiting further, here’s a step by step process to create a survey using Salesforce flow.
Step 1: Create an Object
The first step is to create an object in the Salesforce system which will save the values of the survey. Usually it means creating some custom fields in the object depending upon your requirements and the actual script of the survey. By script I mean the information you are collecting through the survey. In addition, you would also need to record customer related information to the object as well like name, email address, contact information etc. For the purpose of this post we can name the survey object a survey_latest.
Survey Object : survey_latest
Custom Fields of the survey object:
Step2: Create a new flow
The next step is to create a new flow. Go to Setup -> App Setup -> Create -> Workflows & Approvals -> Flows -> New Flow. This will open a new Flow canvas that we can use to create and structure our Flow.
Before we continue it is imperative to understand the workflow of the survey first. Every survey follows a flow chart. Ours is also a very generic survey workflow which starts with a customer greeting screen. This screen will display the greeting message and will ask the user’s permission to proceed further on towards the survey.
If the answer is Yes, we will move on to survey screen from where we will move to thank-you screen. However if the answer was negative, we will skip the survey section and display the thank-you screen.
It is the most basic workflow and common practical surveys involve 3 to 4 survey screens before moving to the ending screen. But the ultimate choice is with the developer of the survey workflow.
Step 3 : Creating Starting screen
Now in your flow screen you will notice on the left a palette panel. It has nearly all types of features a flow may have. The first step is to drag an drop a new Screen element to the workflow canvas and name it Customer greeting_screen, or any name you want.
Add display text field to the screen and configure it to display your starting message.
The next field is to record the user’s consent for participating in the survey. You can use a text field for the same in which a user can type the desired value, but for simple single choice questions radio buttons are the best. So go ahead and chose a radio button type to add to the screen.
Create a new Choice, label it and give it unique name like postive_participation. Similarly create another choice for negative participation. Unique names and labels are important so they must be used cleverly.
Step 4: Creating a Decision Element
Now you are in a situation where you shall be recording the decision of the user. Here we are going to use Decision element from the palette. The decision element can be used to check the validation of multiple inputs and then automatically decide the direction of the Salesforce visual flow.
For this example create a new outcome labeled Yes. In it, configure the values of resource, operator and value in such a way the value of resource customer_reponse_radio is equal to positive_participation, then it will move on to survey screen.
Step5: create the survey screen
By now you have an understanding how you can create screens and add input fields in the screen. So using that create your survey screen. While creating input fields keep in mind the custom fields that you have created in your survey_latest object.
Step 6: Store the value in the object
Now we are going to store the values entered in the survey as an object. From the Palette table choose the Record Create element. While configuring the element, in the Create Field, choose the object in which you want to save the values. Then match the field with input values. Click OK.
And then in Flow canvas screen drag a node from the survey screen element to the record create element. Now the only thing left is to create the thank-you page
Step 7: Create survey ending screen
The last step is to create thank-you screen and link it with the Decision Element that we have used to check user consent and the record create element (i.e. the step after the survey is done.)
Now the most important step, save your survey. It’s best to keep saving your survey in between steps to ensure backup of the work.
Adding the flow to a Visualforce page
As we said earlier, Flow are the best feature for a Visualforce user. It’s because you can add a flow to any Visualforce page via a three line code.
<apex:page > <flow:interview name=”Customer Survey”/> </apex:page>
And that’s how you just embedded you flow in your Visualforce page.
Flows are awesome for creating apps fast