Creating a variable

A variable is used to store the value. You can use the variable throughout your Flow, for example, while creating the record, performing an update, or with delete operations.

An example business scenario: Robby Williams is working as a system administrator in Universal Container. Currently, he is developing a Visual Workflow and wants to create a variable to store customer names.

To create a 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.

    Note

    If you are using Flow for the first time, then it will pop up a welcome page. On the bottom of the page, you can see the Don't Show Again checkbox. If you want the Flow page to load faster, then select this checkbox.

  3. Navigate to the Resources tab, and double-click on the Variable option available under the CREATE NEW section, as shown in the following screenshot:
    Creating a variable

    This will open a window for you, where you have to enter the following details:

    • Unique Name: Enter a 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.
    • Description: Write some meaningful text so other developers/administrators can easily understand why this variable has been created. When you select the variable in the Explorer tab, then this description appears in the Description pane.
    • Data Type: This determines which types of value a variable can store. Select the data type as Text. Available data types for variable are:

      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

    • Scale: This is only available when the data type is set to Number or Currency. Scale is the number of digits to the right of the decimal point.
    • Input/Output Type: This defines whether a variable is available within the Flow or can also be accessed outside the Flow. The different input/output types are:

      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 you can access a variable's value from Visualforce controllers and other Flows

      Input and Output: This means you can set a variable's value at the start and access it's value outside the Flow

      In our case, select Input and Output.

    • Default Value: This allows you to set a default value for the variable. You can either manually enter the value or use the drop-down list to assign the value of a Flow resource as the default. In our case, select {!$GlobalConstant.EmptyString} available under GLOBAL CONSTANT. This will look like the following screenshot:
    Creating a variable
  4. Click on the OK button.

Note

For best practices in this book, we will be using VarT as the prefix for the Text variable, VarN for Number, VarC for Currency, VarD for Date, VarDT for DateTime, and VarB for the Boolean variable type.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.64.66