Brian Kwong, our VP of Delivery & Operations, presented at the Salesforce World Tour in Chicago Thursday. He introduced two use cases for combining Visual Workflow and the new Lightning Process Builder. Due to the time limitations, he was unable to provide a detailed look at how each of the Processes and Flows were built. As promised, here is that overview.
Opportunity Product Discount Setter
Getting approvals for certain discounts can be very important to organizations. Perhaps you’ll allow a 5% discount, but anything greater should be approved. It’s also important to ensure that the discount approved is correctly applied to all the Opportunity Products. It can be very easy to miss or enter the incorrect discounted Sales Price for a product.
Using a combination of Process Builder and Flow we can simplify the process for our Salespeople.
Process Builder works similarly to Workflow Rules. Instead of having separate rules with “entry criteria,” the Process Builder uses a string of Criteria Diamonds. Each Diamond can be considered it’s own Workflow Rule with its own actions.
The Process is built for Opportunities and calls actions when the Opportunity record is created or edited. Then we have a criteria diamond for each of our Discount options: List Price, 5%, 10%, 15%, and 20%. We also have three extra criteria diamonds: when the 15% or 20% Discount is approved and when the discount is rejected.
In this situation, the actions are used to update all products’ “Discount” field, Submit for Approval, and call our Flow to update the Sales Price on each product. In our example, you only need approval for 15% and 20%. The 5% and 10% diamonds do all three actions, while the 15% and 20% only submit for approval.
Once approved, we have our 15% Approved and 20% Approved Criteria Diamonds that will call the additional actions to set the Discount value and call the Flow to update our Sales Prices.
The Flow is intended to be used regardless of what the value of the discount is. We have two variables marked as “Input and Output.” The first, is the OpportunityID (vrOppId) and the second is the discount value (vrDiscount). Values for both of these variables are passed to the Flow as part the action within Process Builder.
We also have a Formula variable (vrPrice) that references the list price of our single Product variable ( vrThisProduct defined in our loop) and multiply it by our Discount variable (vrDiscount).
Once we have the two variables and formula defined, the Flow does the following:
- Look up the Opportunity with a Record Lookup
- Use Fast Lookup to get a list of the Opportunity’s Products and save in a sObject Collection variable
- Loop through each product and set the Sales Price to our formula variable
- Assign each product to a new sObject Collection
- Once the loop is completed, use a Fast Update to update all the Products
Renewal Opportunity Creator
Many organizations have subscription models that require users to create an Opportunity to reflect the Renewal. This can range from being very easy on the user, to being quite difficult depending upon the circumstances. Users can easily forget to create a renewal Opportunity or incorrectly enter data. Automating this process used to require APEX code, but no longer!
The Process for this use case is very simple. We’re going to have a single criteria diamond where the criteria is the Opportunity has changed to Closed Won. We will then have a single immediate action that calls our Flow. If we needed to, we could change this so our Renewal Opportunity is created on a schedule. For example, 90 days after the close date or perhaps 60 days before the expiration date – assuming the expiration date is on the Opportunity.
This Flow is fairly simple with only 7 elements (8 if you count the fault error message). At the basic component we’re going to do the following.
- Query the source Opportunity with Record Lookup and grab any important information
- Query all Opportunity Products on the Opportunity and store it in an sObject Collection variable
- Create the renewal Opportunity with Record Create based on the source Opportunity
- Loop through each Opportunity Product, creating a new record
- Add the new record to a second sObject Collection Variable
- Once all products have been reviewed, use Fast Create to create all the new products
Are you looking at learning more about Flows and Process Builder?
Check out Brian’s Salesforce CRM training series on YouTube called Wizard’s Apprentice. Each video covers a different element, use case, or best practice.
You can also check out the many other blog posts written by Brian at TheWizardNews.com with posts covered a variety of topics.
We also recommend Salesforce’s Trailhead a great place to learn and receive points and badges. We hope you enjoyed reading our post on How Process Builder and Visual Workflow Work Together!