Performance Management is a mission-critical Apex-driven calculation engine that automates complex multi-dimensional commission splits, team production ratios, and real-time agent performance metrics for a high-growth brokerage. It is a scheduled APEX job that makes use of a custom APEX class that includes batch work to handle large quantities of records.
Tools: APEX Class, APEX Batch, APEX Scheduled Job, Custom Object
As the brokerage scaled, the complexity of managing agent commission structure, factoring in team sizes, regional requirements, and varying member role, surpassed the capabilities of manual spreadsheets and out-of-the-box platforms. The business required a flexible, proprietary system capable of calculating "moving target" metrics, such as rolling lead conversion rates and tiered production hurdles. Without an automated solution, the brokerage faced significant risks in payment accuracy and an inability to provide agents with real-time eligibility feedback.
Enter the Performance Management (PM) Apex Class, a robust computational framework designed to handle deep data aggregation across Lead, Transaction and People objects. By keeping this logic "in-house" via custom code, the brokerage gained the agility to pivot commission structures and lead-claiming rules instantly as business needs evolved. This system serves as the single source of truth for agent production, providing the data foundation for both the Lead Eligibility Flow and executive management reporting.
The system operates as a high-performance scheduled Apex job that executes hourly, utilizing Batchable Apex and Map/Set collections to process the entire agent roster without exceeding Salesforce governor limits. By leveraging Aggregate Results to query thousands of transaction records simultaneously, the engine performs deep-dive calculations for Last Twelve Months (LTM) metrics, including lead-to-close conversion rates, broker dollar contributions, and overdue follow-up percentages. For agents within team structures, the code dynamically analyzes team compositio, distinguishing between regular and sub-team role, to generate custom production ratios and tiered commission splits based on regional requirements. This programmatic precision ensures that all calculations, including manual overrides, are mathematically indisputable across both individual and parent team records. Furthermore, the inclusion of "shortcut" triggers allows for immediate, on-demand recalculations on specific records, providing the brokerage with an agile, in-house solution that can be updated instantly to meet evolving business requirements without the costs or delays associated with third-party platforms.