Hands on 8 – calling a Flow from Process Builder

Process Builder allows you to launch a Flow. Process Builder is another way to auto-launch a Flow. For example, there is a Flow that allows for the removal of followers from closed opportunity records. If you want this Flow to automatically execute whenever the opportunity status gets closed, you should use Process Builder. 

Some Flows don't require any user interaction to start; for example, a Flow of the type Autolaunched Flow. An Autolaunched Flow can be launched without user interaction; from Process Builder or the Apex interview.start method, for example.

Let's look at a business scenario. Suppose that Sara Bareilles, who is working as a system administrator at Universal Containers, has created a Flow to create a new opportunity using the Record Create element, as shown in the following screenshot:

Currently, she is using a custom button on the Account Page layout to call the Flow. She wants to use Process Builder to automatically fire the Flow whenever an account gets created. The VarD90DaysFromToday object is a date variable, and the VarTAccountId and VarTAccountName variables used in the preceding example are nothing but text variables. We will use Process Builder to pass the values in these variables.

Follow these instructions to call a Flow from the process:

  1. Create a Flow, similar to what is shown in the preceding screenshot; save it with the name Create an Opportunity. The Type should be Autolaunched Flow. Click on the Close button to close the canvas. Don't forget to activate the Flow:
  1. To create a process, navigate to Setup (gear icon) | Setup | PLATFORM TOOLS | Process Automation | Process Builder, click on the New Button, and enter the following details:
    • Name: Enter Auto create an Opportunity in Name.
    • API Name: This will be auto-populated, based on the Name field.
    • Description: Write some meaningful text, so that other developers or administrators can easily understand why this process was created.
  2. Once you are done, click on the Save button. It will redirect you to the process canvas, which will allow you to create the process.
  3. After defining the process properties, the next task is to select the object upon which you want to create a process and define the evaluation criteria. For this, click on the Add Object node. This will open an additional window on the right-hand side of the process canvas screen, where you will have to enter the following details:
    • Object: Start typing the name, and then select the Account object.
    • Start the process: For Start the process, select only when a record is created. This means that the process will fire only at the time of record creation.
    • Recursion: Allow process to evaluate a record multiple times in a single transaction?: Select this checkbox only when you want the process to evaluate the same record up to five times in a single transaction. In this case, leave the box unchecked.
  1. Once you are done, click on the Save button.
  2. After defining the evaluation criteria, the next step is to add the process criteria. To define the process criteria, click on the Add Criteria node. This will open an additional window on the right-hand side of the process canvas screen, where you will have to enter the following details:
    • Criteria Name: Enter Always as the criteria name.
    • Criteria for Executing Actions: Select the type of criteria that you want to define. You can select either Formula evaluates to true, or Conditions are met (a filter to define the process criteria), or No criteria-just execute the actions! In this case, select No criteria-just execute the actions! This means that the process will fire in every condition.
  3. Click on the Save button.
  4. Once you are done with the process criteria node, the next step is to add an immediate action to launch a Flow. For this, we will use the Flows action, available in Process Builder. Click on Add Action, available under IMMEDIATE ACTIONS. This will open an additional window on the right-hand side of the process canvas screen, where you will have to enter the following details:
    • Action Type: Select the type of action. In this case, select Flows.
    • Action Name: Enter Auto create new Opportunity in Action Name.
    • Flow: Select the Flow that you want to execute. In this case, select the Create an Opportunity Flow.
    • Set Flow Variables: Use this to pass the value in your Flow variables. For the current use case, map the VarD90DaysFromToday variable with the formula TODAY() + 90, the VarTAccountId variable with [Account].Id, and the VarTAccountName variable with [Account].Name.

The immediate actions will look as follows:

  1. To assign the value to multiple variables, click on the Add Row link. Once you are done, click on the Save button.
  2. The final step is to activate the process. Click on the Activate button, available on the button bar. Finally, the process will appear, as shown in the following screenshot:

From now on, if an account gets created, Flow will automatically be executed by Process Builder, and a new opportunity will be created.

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

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