Learning Salesforce Visual Workflow and Process Builder(Second Edition)
上QQ阅读APP看书,第一时间看更新

Hands on 3 - displaying a feedback form based on conditions

Let's start with an example: Sara Bareilles is working as a system administrator for Universal Containers. She has received a requirement from her customer success manager to develop a feedback form (containing name, e-mail address, and a rating radio button). Her manager wants to display feedback only when the user's age is greater than 18, and he also wants to expose this visual Flow for unauthenticated access (to people who are not Salesforce users).

To develop this Flow, it's necessary that we first ask for the age as user input, then use the Decision element to check the age; if the age is greater than 18, it will display a feedback form or a sorry message. To develop the Flow, follow these instructions:

  1. Navigate to Setup | Build | Create | Workflow & Approvals | Flows.
  2. Click on the New Flow button; it will open the Flow canvas.
  3. Then navigate to the Palette tab, and drag and drop the Screen element on to the canvas; it will open a Screen element window.
  4. Enter the Name field as Enter your age; you can also add description. Under the Navigation Options section, select Don't show Previous button from the drop-down. Optionally, you can add Help Text as well.
  5. The next task is to add a Date field onto the screen to allow your users to enter their date of birth. On the Screen element, navigate to the Add a Field tab and double-click on the Date field, which is available under INPUTS, to add it to the screen. In the Screen overlays preview pane, click on the Date field to configure its settings by filling out the Label, Unique Name, and Default Value fields, and selecting the Required checkbox under the General Info section, as shown in the following screenshot:
  6. Also, add a validation rule so the user can't enter a future date. To achieve this, use the Date_of_birth < Today() formula.
  7. Now, we will create a formula field to calculate the age from the date of birth field. To create a formula, navigate to the Resources tab and double-click on Formula, which is available under the CREATE NEW section, and create a formula as shown in the following screenshot:

Here, {!Date_of_birth} is the screen input element that we have created in step 5.

  1. Once you are done, click on the OK button.
  2. Now we will use the Decision element to check the age.