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

Creating a collection variable

Collection variables are used to store multiple values of similar data types; for example, a group of e-mail addresses. Once you have populated a collection variable with values, you can use it throughout the Flow.

Here is a business Scenario: Helina Jolly is working as a system administrator for Universal Containers. Currently, she is developing a Visual Workflow and wants to create a variable to store customers' e-mail addresses to send out an e-mail to them.

To create a collection variable in your 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 for you.
  3. Then navigate to the Resources tab and double-click on Collection Variable, which is available under the CREATE NEW section. It will open a window for you, where you have to enter the following details:
    • Unique Name: Enter the unique name. The name must begin with a letter, and use only alphanumeric characters and underscores. Uniqueness applies only to elements within the current Flow. In this case, enter CovEmailAddress.
    • Description: Write some meaningful text so other developers/administrators can easily understand why this Collection variable was created. When you select a collection variable in the Explorer tab, then the description appears in the Description pane.
    • Data Type: This determines which types of value variables can be stored. Select the data type of Text. The available data types for variables are as follows:
      • Text: This is used to store any combination of letters and numbers.
      • Number: This is used to store any numbers.
      • Currency: This is used to store currency.
      • Date: This is used to store the date.
      • DateTime: This is used to store the date with the time.
      • Boolean: This is used to store either true or false.
      • PicklistThis is used to store a picklist value. It supports the ISPICKVAL() function in flow formulas.
      • Picklist (multi-select): This is used to store multi-select picklist values.
    • Input/Output Type: This defines whether a variable is available within the Flow or can also be accessed outside the Flow. Different input/output types are as follows:
      • Private: This variable can be allocated and used only within the Flow.
      • Input Only: This allows you to set a variable at the start of the Flow using Visualforce controllers, URL parameters, or subflow inputs.
      • Output Only: This means that you can access a variable's value from Visualforce controllers and other Flows.
      • Input and Output: This means that you can set a variable's value at the start and access its value outside the Flow.

This will look like the following screenshot:

4. Once you are done, click on the OK button.

For best practice, in this book we will use  Cov as the prefix for a Collection Variable.