Blog

When building in Salesforce, it is essential to keep in mind the order of execution of the different components that make up a Salesforce build. These components consist of almost anything you can think of, from Point-and-Click to well-written code. In the image below, you can see the order of operations that Salesforce follows when taking such components into account.

An example of a basic order of operations can be: first looking at validation rules, then looking at before triggers, followed by after triggers, and then lastly workflow rules and process builders. While this is a simplistic look at the system, it is a good flow to use as a guide for maneuvering around the perils that can exist when building in Salesforce but not taking the order of operations into account.

"An example of a basic order of operations can be: first looking at validation rules, then looking at before triggers, followed by after triggers, and then lastly workflow rules and process builders."

First up in possible errors is the ever so hated, FIELD_CUSTOM_VALIDATION_EXCEPTION error. This is most commonly seen on workflow rules, process builders, and even triggers. The cause of this error is always the same: whoever built the logic forgot to check if there were validation rules in place, either on the object at hand or on a related object that is impacted by the change attempted to be made.

The creator of the Process Builder forgets entirely to check the validation rules when building and, therefore, does not populate nor checks to see if that checkbox is marked correctly. Hence, on the first round of testing they do, the above error pops up. They must now see what validation is in place that is preventing the action from occurring.

Of course, this example is highly simplistic, but imagine a scenario with 50 validation rules and 10 process builders and three triggers. If you didn’t remember to check these things, you could end up with a whole host of issues on your hand. The same also goes for the inverse. Don’t forget to update processes that fire when validation rules are added up or updated.

Alright, onto another example. This one is more common in the coding world of Salesforce but does play its hand heavily on the Point-and-Click side too (although more commonly forgotten): the dreaded reliance on data from another flow. There is an order of operations to keep in mind even amongst the process you can have in place. There is a reason why Salesforce is pushing folks away from workflow rules into process builders, and why they established the process of one trigger per object. They both boil down to not knowing what will fire first. In the context of triggers and process builders, if you have too many that act at the same time on the same object, you lose control over which should fire first.

Again, let’s go with a simple example. I created a Process Builder that fires on the Opportunity and updates the Stage to 'Commit' when a checkbox called Commit is marked 'True'. This Process Builder fires on both create and edit with no conditions. At the same time, I have a workflow rule that sets the Checkbox to 'Commit' anytime the user changes the Forecast stage. This workflow rule also fires on anytime an Opportunity is created or edited. While most of the time you may see this work, you are relying on two processes that can fire at the same time; meaning, the action of the Process Builder could be missed if it tries to fire at the same time as the workflow rule.

It is crucial to handle these types of processes across the board (flow, triggers, workflow rules, and process builders) with care. Many of them can fire in orders you do not expect and thereby leading to unexpected results. You can also end up with an infinite loop, depending on the criteria in place as they may keep causing new rules to fire, that then lead to older rules firing, and the process repeating. Ending up in this scenario can result in CPU overages or locked out records — neither of which are fun or easy to diagnose.


The recommendation here is to ensure your processes are singular in nature per object and per event type. Make sure to follow the One Trigger Per Object methodology as well as the One Process Builder Per Object methodology to help ensure you do not run into these issues. Today, Salesforce doesn’t display anything to the user for triggers, but if you try to create a new Process Builder on an object that already has one, you will be warned.

Honestly, this list of example could go on for days. All you need to do is to look at the developer forums on Stack Exchange for Salesforce and you will see errors left and right. While not all of them have to do with the Order of Execution, quite a lot of them can be boiled down to something related to it. 

The Order of Execution is something to always keep in mind, whether you are creating Assignment Rules or Auto-Response rules. Monitoring the timing and the impacts a change can make will help keep your org healthy over time. I write this coming from a place of having forgotten to keep this in mind myself and spending hours trying to resolve incorrect emails going out (workflow rules vs. case settings vs. assignment rules) or trying to understand a flow error.

 You can save and print the Save Order of Execution Diagram from the link below.  

What Certification are you studying for now?

Focus on Force currently provides practice exams and study guides for nine certifications

Common Pitfall Errors as a Result of “Order of Execution”

When building in Salesforce, it is essential to keep in mind the order of execution of the different components that make up a Salesforce build. These components consist of almost anything you can think of, from Point-and-Click to well-written code. In the image below, you can see the order of operations that Salesforce follows when taking such components into account.An example of a basic order of operations can be: first… Read More

Common Pitfall Errors as a Result of “Order of Execution”

Focus on People: Mikael Petersson – Combining Two Passions: Technology and Business

Mikael is passionate about technology and business, most especially in the synergy of the two. He discovered he can find both of these in Salesforce.At first, he struggled to get to know the platform and all the possibilities and features it offers. He worked hard to get his first certifications – Admin then Advanced Admin. Now, four certifications and lots of projects later, he’s found the sweet spot of where… Read More

Focus on People: Mikael Petersson – Combining Two Passions: Technology and Business

Focus on People: Dominick DeFazio – From Sales to Lead Dev

Dominick was in sales when he started his Salesforce journey. As a user, he was frustrated with how the org was set up for the functions that he would use everyday. Determined to improve their team’s processes, he tried to learn Salesforce configuration and went straight to pursuing a PD1 Certification.​Read about his insights and tips to help others achieve a rapid on-the-job learning of Salesforce that enabled him to… Read More

Focus on People: Dominick DeFazio – From Sales to Lead Dev

Focus on People: Nat Sullivan – From Start by Accident to Start with Confidence

Nat had never heard of Salesforce when she was offered an internal position by her company to be the Salesforce Trainer for North America. Coming from an end-user non-technical background, it felt like she was pushed into deep waters, and forced to swim.  Read how her Salesforce journey has led her to the most challenging, yet the most rewarding experiences of her life. In this interview, she tells us about the… Read More

Focus on People: Nat Sullivan – From Start by Accident to Start with Confidence

Focus on People: Julian Virguez – From Java To Salesforce Developer

Read how the Salesforce platform has helped a Java developer to learn and improve his programing skills on a whole new level.  Julian worked as a Salesforce developer in a consulting company. He has been working with Salesforce for more than 5 years and he has so many useful things to share with our community. Keep reading and find out more about Julian’s Salesforce experience and learning process.What is your role… Read More

Focus on People: Julian Virguez – From Java To Salesforce Developer

Understanding Salesforce Email Integration

by Martin Gessner Do you ever get confused about all of the different options available for working with email and Salesforce? I do, and so we created a one pager overview diagram. It is broken up by use case or scenario. Get the Email Integration Options PDF Download PDF   Gmail / OutlookIf you use Outlook or Gmail for your email, you have a few options. To start with, there… Read More

Understanding Salesforce Email Integration

The Small Things that Go a Long Way – The Importance of Configuration Descriptions in Salesforce

by Mary Mendoza Adding comments and descriptions to configuration changes in Salesforce may take a minute now, but may save you hours in the future. Read on to understand why getting into this habit is a best practice that you want to ensure you are following now!I was just reading an email post from Jen Lee about Flow and automation and she mentioned that everyone should provide descriptions for their… Read More

The Small Things that Go a Long Way  – The Importance of Configuration Descriptions in Salesforce

Focus on People: David Paradise – Finding Yourself On A New Path And Coming Out A Winner

Often, your job tasks or your role could be the reason for learning Salesforce and getting certified. In David’s case, he had to learn Salesforce because he started working for Salesforce after an acquisition.David is currently a Senior Quality Engineer at Salesforce Commerce Cloud. Discover the interesting story of how he had to dive right in to getting his Trailhead wins and his first Salesforce certifications.How and Why did you… Read More

Focus on People: David Paradise – Finding Yourself On A New Path And Coming Out A Winner

Salesforce Round Robin Lead and Case Assignment

Imagine your leads or cases as a deck of cards. Now you want to distribute the deck evenly among five players on the table – the players being agents or sales reps in your company. What you do is deal one card at a time to player 1, then 2, then 3, then 4, then 5, then back to player 1 and so on, until all the cards are dealt…. Read More

Salesforce Round Robin Lead and Case Assignment

Focus on People: Andrew Sullivan

Getting a Certification At the Start of My Salesforce Journeyby Aleksandra KrstevskaFor those who are still at the beginning of learning and experimenting with Salesforce platform, this interview will be a real motivation for taking the next big step.We had a great interview with Andrew Sullivan who is a Senior QA Analyst and is working part-time as a Salesforce developer. He is still at the beginning of his Salesforce journey… Read More

Focus on People: Andrew Sullivan

Focus on People: Ken Seaney

specific learning techniques to get your Salesforce certificationby Aleksandra KrstevskaKen Seaney has some great advice on how to use specific learning techniques to get your Salesforce certification. He is an independent contractor experienced in Lightning, Process Builder and creating Flows, workflow rules, formulas and automated alerts.In this interview he is explaining his preparation process for a specific Salesforce certification. We all can learn something useful from his specific learning techniques,… Read More

Focus on People: Ken Seaney

What Happened to Assistly.com?

Assistly.com was founded in 2009 to create a better customer service app for small businesses. The idea was to create a single interface that allowed business to respond to customer support requests across all channels — especially social media channels. Those support requests were stored in a CRM (Customer Relationship Management) backend, which then allowed Assistly to provide its clients with data and metrics on case volume, response time, channels… Read More

What Happened to Assistly.com?