This chapter covers how to track Monthly Recurring Revenue (MRR) in Salesforce by automatically generating Monthly Revenue Event records. Instead of viewing revenue only at contract turnover, this approach provides a continuous, month-by-month view of recurring revenue trends.

By leveraging Apex automation and Flows, we can ensure that every Closed Won Opportunity generates MRR records, accurately reflecting revenue movement over time.

Data Model

First, introduce the Monthly Revenue Event (MRE) object to track recurring revenue. This object links to Accounts and Opportunities through Master-Detail relationships, ensuring data integrity. Key fields like Month, Type, and Amount provide the foundation for tracking and reporting revenue trends. This object provides the necessary structure for the Apex class to generate MRE records automatically when Opportunities are closed.

Figure 1: MRE Object Schema

Figure 1: MRE Object Schema

Untitled

YouTube Series Embed:


User Experience

After creating the Monthly Revenue Event (MRE) object, build on the existing Opportunity page layout by adding MRE’s as a related list. This enhancement allows users to view MRR breakdowns directly from the Opportunity record, alongside other key fields and related lists.

Figure 2: Sample Opportunity Page Layout With MRE Records

Figure 2: Sample Opportunity Page Layout With MRE Records


Automation

Monthly Revenue Event (MRE) records are generated using a combination of Apex automation and a Record-Triggered Flow, ensuring revenue events are accurate and always up-to-date.

Invocable Apex Class

The Apex class calculates and generates MRE records when triggered. It is designed as an invocable method, meaning it can be called directly from a Flow for seamless automation. The class deletes existing MRE records tied to the Opportunity to prevent duplication. Using fields from the Opportunity object, it calculates and classifies revenue movements for precise revenue tracking.