Chapter 1. Getting Started with Visual Workflow

This chapter starts with an overview of Visual Workflow (also called Flow) and its benefits, which take the discussion forward to the various business requirements where we can use Flow. We will discuss various business problems and how we can develop an application without using code to solve them. By the end of this chapter, you will have learned various ways to invoke a Flow and the fundamentals of Visual Workflow.

In the next few chapters, you will be briefed about various concepts related to Visual Workflow and learn numerous ways to create point-and-click tools without using code. We will also see different ways to streamline our sales process and automate our business process using a Flow. In the last few chapters, we will go through how to automatically launch a Flow using Process Builder. The following topics will be covered in this chapter:

  • Business problems
  • The benefits of Visual Workflow
  • System requirements for using Visual Workflow
  • An overview of the Visual Workflow lifecycle
  • An overview of the Cloud Flow Designer
  • An overview of Visual Workflow building blocks
  • The various ways to invoke a Flow

Visual Workflow is a drag and drop interface that allows you to automate business processes by creating applications using click not code. Using Visual Workflow we can create, update, edit, delete, send an e-mail, submit records for approval, post to chatter, and take user input in Salesforce and then make those Flows available to the business users or systems. Visual Workflow can execute business processes, interact with the database, invoke Apex classes (an Apex class implements the Process.Plugin interface), and create a series of screens to take user input in order to collect and update data in Salesforce and Flows can also be built with no user interface to allow them to be run from automated processes.

Business problems

As a Salesforce administrator or developer you may get multiple business requirements from businesses to streamline the processes. Many of them are achievable by using out of the box (OOB) concepts, and for others, we have to use Apex or Visualforce pages. Visual Workflow gives us another method that will let us implement many business processes without needing custom coding. A few examples are discussed in the following sections.

Business use case 1

Sara Bareilles is working as a Vice President, Sales, in a company named Appiuss. She wants to auto close all the open opportunities with the Closed Lost stage, when an account out of business field (that is, custom field) is checked.

There are several ways to solve the given business requirement; these are mentioned in the following sections.

Solution 1 – using an Apex trigger

Because this requirement means that many child records (opportunities) need to be updated when a parent record (Account) is edited, we can't achieve the preceding business requirement using the Workflow rule. The next possibility is to use an Apex trigger. Generally, a developer writes an Apex trigger on the Account object to update all the open opportunities when an account's custom field, out of business, gets updated to True. The following is the sample code:

trigger UpdateRelatedOpportunites on Account (after update) {
  for (Account AccountToUpdate : trigger.new)
    {
        If (AccountToUpdate.Out_Of_Business__c==True)
        {
        // Your logic;
        }
    }
}

In addition, you'll need a test class, and then use a change set to deploy the trigger and test classes to production. This also means that any change to the business logic will require more development work.

Solution 2 – a combination of Visual Workflow and Process Builder

Another way to achieve the same business requirement is to use a combination of Visual Workflow and autolaunch Flow/Process Builder. Here is the description of the next screenshot:

  • A sample Flow update all the open Opportunity stage to the Closed-Lost related to an account which is marked as out of business
  • A process on the Account object, it will fire when the out of business checkbox is checked

The following screenshot represents solutions for a similar business scenario by using Visual Workflow and Process Builder:

Solution 2 – a combination of Visual Workflow and Process Builder

Process Builder is one of the ways to automate complex business processes using click not code similar to the Workflow rule and Visual Workflow. We will discuss more about this in Chapter 5, Developing Applications with Process Builder.

Business use case 2

Robby Williams is working as a Customer Success Manager in Appiuss. He wants to send a reminder e-mail on a weekly basis to all the users who don't have a profile picture on Chatter.

Again, there are plenty of ways to solve this requirement. Some of the ways are as follows.

Solution 1 – using Apex

We can't achieve this goal by the Workflow rule. For this, we have to write an Apex class that implements the Schedulable interface for the class and then use Schedule Apex to run it on a regular basis. The following is the code for this Apex class:

global class SendChatterEmail implements Schedulable
{
    global SendChatterEmail (){
      // Batch Constructor
    }

    // Start Method
    global Database.QueryLocator start(){
      /* Use SOQL query to get the records you want to operate upon
      select Id, fullPhotoUrl from User where isactive = true AND FullPhotoUrl    like '%photo/005%'*/
    }

    // Execute Logic
    global void execute(){
      // perform the operation

    }

    global void finish(){
      // Logic which we want to execute at finish
    }
}

Solution 2 – a combination of Visual Workflow and Process Builder

An alternative way to accomplish the same business requirement is to use a combination of Visual Workflow and Process Builder. Here is the description of the next screenshot:

  • This represents a Flow to send e-mail alerts to all users, who do not have profile pictures on Chatter
  • This represents the Flows action from Process Builder on a custom object (reminder notification) to trigger our Flow

The following screenshot represents the solution for business scenario 2 using Visual Workflow and Process Builder:

Solution 2 – a combination of Visual Workflow and Process Builder
..................Content has been hidden....................

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