Skip to main content
salesforce help

How to Avoid the Pitfalls of Salesforce Triggers

THE BRIEF

The client, a 60 year old established B2B leader in their industry, was undergoing a digital transformation to support and optimize their national operations. In 2009, they adopted Salesforce as their primary platform to unify and expand their sales operations. Today, they are completely operational on the platform, leveraging marketing, sales, service and field service lightning. The decade old system organically grew into inconsistent and impaired processes being developed by disparate teams. This adversely impacted the performance and efficiency once intended to be the value drawn from the Salesforce platform.

THE CHALLENGE

One of the attractive capabilities of Salesforce is its automation. Repeatable processes that are often mundane and costly for humans to maintain are suitable use cases for Salesforce automation. The client took advantage of this across multiple business units, automating as much as they could in order to become more efficient in their performance. The challenge became apparent to the client as they noticed certain automated triggers misfiring, or worse, not firing at all. 

A trigger is Apex code that executes before or after the following types of operations:

  • insert.
  • update.
  • delete.
  • merge.
  • upsert.
  • undelete.

In the case of the client, multiple triggers were created, often without documentation or the ability to trace where the trigger is firing, leaving the client with competing executions that would misfire, preventing the automation from working. Records that were updated by customer service reps were not able to be saved, preventing other related records that were meant to be automatically updated from taking place. The more triggers they created the more complex the challenge became as the developers failed to document where an automated trigger starts and where it ends.

THE SOLUTION

The client partnered with Saggezza to consolidate Salesforce triggers to improve the overall performance of their Salesforce instance by controlling the order of execution for the existing trigger functionality. New documentation defining each trigger and its process was also developed to support the maintenance and growth of the platform, previously, no documentation existed. 

THE RESULTS

In the end, the client increased user performance by 45% and the development team reaped the benefits of gaining visibility into the consolidated set of triggers in the following ways:

• Reusability: There will be no need to copy code 

• Simplicity: every “trigger” was reduced to just two lines of code in the master trigger, leading to an object-oriented codebase that is more organized, predictable, and modular too. 

• Control Execution Order: in Apex, “the order of execution isn’t guaranteed for multiple triggers on the same object.” All triggers for the client were consolidated to one per object ensuring they fire in a controlled environment. 

• Debugging Issues: It will be easier to debug any issues from the triggers/classes. The primary advantage is control of execution.

Saggezza is a proven technology and consulting partner that delivers personalized, high-value solutions to accelerate business growth.

Share This
Related Projects
Open API Ecosystem for Retail Industry Leader

Integrated solution for sharing data services from multiple business functions using APIs. This included a new enterprise system using lightweight […]

Prioritizing Mobile Capabilities: How to Improve the Customer Digital Journey

The omni-channel journey of national restaurant chain THE BRIEF A national restaurant chain sought to modernize their digital presence by […]