Chapter 7. Optimizing Business Processes with Visual Workflow and Approval Processes

In the previous chapters, we discussed Salesforce Service Cloud. Service Cloud is a product designed to automate support processes. By implementing it, you can boost your support agents' productivity by allowing them to manage customer issues in a faster and simpler way. This chapter will start with an overview of Visual Workflow and its benefits. We will then take the discussion forward to the various business requirements where we can use Visual Workflow. Then, we will go through Visual Workflow's basic concepts. In addition to this, we will also look at how to set up an approval process in Salesforce. The following topics will be covered in this chapter:

  • Business problems
  • Benefits of Visual Workflow
  • Overview of Visual Workflow's life cycle
  • Overview of Cloud Flow Designer
  • Creating a calculator to display summation of two numbers
  • Approval process

A Visual Workflow is a drag and drop tool that allows you to automate business processes by creating an application that uses click not code. Using Visual Workflow, you can create records, update records, delete records, send an e-mail, submit a record for approval, post to Chatter, capture user input in Salesforce, and then make those flows available to business users. You can also execute logic with the help of record or fast elements, interact with the database, invoke an Apex class (an Apex class implements the Process.Plugin interface), and create a series of screens to capture user input for saving and processing data in Salesforce.

Business problems

As a Salesforce administrator or developer, you may get various requirements from the business to streamline the sales or support processes. As per our experience, we can say that many of them are achievable only if you make use of the out-of-the box features. For a few instances though, you would need to use either the Apex or Visualforce Page. Visual Workflow gives us a way to implement various business processes without using the Apex or Visualforce Page. We'll discuss more examples of this in a detailed manner in the subsequent subsections.

Business use case 1

A business scenario: David Guzman is working as a System Administrator at Universal Containers. He has received a requirement to create a survey page in Salesforce and expose it to the company's website for unauthenticated access.

There are several ways to solve the preceding business requirement; a few of them are mentioned next.

Solution 1 - Using a Visualforce Page, Apex class, and Force.com site

As the requirement is to capture users' feedback from the company website page, we can't use the standard out-of-the-box page to achieve it. We need to create a Visualforce Page to capture the data. We also need an Apex class to process that data and then expose a Visualforce Page to the Force.com site for unauthenticated access. This approach requires coding skills and is time consuming if you want to update logic in future. This is because here you will have to update both the Apex class as well as the test class.

Solution 2 - Using a Visual Workflow, Visualforce Page, and Force.com site

Another way to achieve the same business requirement is to use a combination of Visual Workflow, Visualforce Page, and Force.com site. Here is a description of the following screenshot:

  • Section highlighted as 1 - This indicates a sample flow to capture the user's input and process data in Salesforce.
  • Section highlighted as 2 - This indicates that you need to embed a Visual Workflow in a Visualforce Page.
  • Section highlighted as 3 - Once you're done with Part 2, expose the Visualforce Page for unauthenticated access via the Force.com site.

Solution 2 - Using a Visual Workflow, Visualforce Page, and Force.com site

Visual Workflow is another way to automate business processes using click not code. To deploy a Visual Workflow in a production org, you don't need to write a test class for it.

Business use case 2

A business scenario: David Guzman is working as a system administrator at Universal Containers. He has received another requirement to auto-delete all Closed Lost opportunities when an account's Active fields (that is, custom fields) are updated as False.

There are several ways to solve the preceding business requirement. A few of them are mentioned in the subsequent subsection.

Solution 1 - Using an Apex trigger

As we can't achieve the preceding business requirement using the Workflow Rule, the next possible solution is to use an Apex trigger. A developer can write an Apex trigger on the Account object to delete all Closed Lost opportunities when an account's Active custom field gets updated to True. The following is a sample code:

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

Solution 2 - Using a Visual Workflow and Process Builder

Another way to achieve the preceding business requirement is to use a combination of a Visual Workflow and Process Builder. The following screenshot represents a solution for a similar business scenario using a Visual Workflow and Process Builder. Here is a description of the next screenshot:

  • Section highlighted as 1 - It represents a sample flow to delete all the opportunities where stage equals to Closed Lost, which is related to an account that gets Inactive.
  • Section highlighted as 2 - It represents a Process Builder on the Account object. It will fire when this is the case: Active == False.

Solution 2 - Using a Visual Workflow and Process Builder

Process Builder is one of the ways to automate complex business processes using click not code, such as Visual Workflow. We will discuss more about it in Chapter 8, Automating Complex Business Processes.

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

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