Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Salesforce Visual Workflow and Process Builder

You're reading from   Learning Salesforce Visual Workflow and Process Builder Flows and automation for enhanced business productivity

Arrow left icon
Product type Paperback
Published in May 2017
Publisher
ISBN-13 9781787284999
Length 448 pages
Edition 2nd Edition
Arrow right icon
Author (1):
Arrow left icon
Rakesh Gupta Rakesh Gupta
Author Profile Icon Rakesh Gupta
Rakesh Gupta
Arrow right icon
View More author details
Toc

Table of Contents (9) Chapters Close

Preface 1. Getting Started with Visual Workflow FREE CHAPTER 2. Creating Flow through Point and Click 3. Manipulating Records in Visual Workflow 4. Debugging and New Ways to Call a Flow 5. Developing Applications with Process Builder 6. Building Efficient and Performance Optimized Processes 7. Building Applications without Code 8. Enabling Flows to Work with Lightning Experience

Business problems

As a Salesforce administrator or developer, you may get business requirements from businesses to streamline the processes. Many of them are achievable 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 Universal Containers. 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 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, Force.com IDE or Force.com Migration Tool, 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 Process Builder. Here is the description of the next screenshot:

  • Section highlighted as 1: In this, a sample Flow updates all the open Opportunity stages to Closed-Lost related to an account that is marked as out of business.
  • Section highlighted as 2: This is the process on the Account object; it will always fire whenever an account record gets created or updated.

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

Process Builder is one of the ways to automate complex business requirements using click not code, similar to the Workflow rule and Visual Workflow. The benefit of using this approach is that you can easily follow the Salesforce best practice to create one process per object and use Visual Workflow to manage logic for multiple business requirements. We will discuss this in Chapter 5, Developing Applications with Process Builder, and Chapter 7, Building Applications without Code.

Solution 3- using Process Builder

Another way to achieve the same business requirement is to use a process created on Process Builder. Here is the description of the next screenshot:

  • A process on the Account object, which will fire when the out of business checkbox is checked
  • Then the Update Records action will be fired, and it will update all the open Opportunity stages to the Closed-Lost stage related to an account which is marked as out of business

The following screenshot represents solutions for a similar business scenario using Process Builder:

Process Builder allows you to automate complex business processes using click not code.

Business use case 2

Robby Williams is working as a customer success manager in Universal Containers. 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:

  • Section highlighted as 1: This represents a Flow to send e-mail alerts to all users who do not have profile pictures on Chatter
  • Section highlighted as 2: 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:

You have been reading a chapter from
Learning Salesforce Visual Workflow and Process Builder - Second Edition
Published in: May 2017
Publisher:
ISBN-13: 9781787284999
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image