Case Study: Salesforce Training Management System
A comprehensive solution for tracking and managing training activities within Salesforce
Project Overview
This project involved building a comprehensive Training Management System in Salesforce to manage the training status of contacts and ensure that the training progress is tracked efficiently. The system integrates custom objects, fields, business logic, Lightning Web Components (LWC), Batch Apex, and Scheduled Apex. The goal was to provide seamless tracking of training activities for each contact and automate status updates based on the training progress.
1. Requirements Breakdown
a. Custom Fields & Objects
New Field on Contact Object:
- Field Name: Training_Status__c (Picklist)
- Options: Not Started, In Progress, Completed
New Custom Object:
- Object Name: Training__c
- Fields:
- Name (Auto-Incrementing)
- Contact__c (Lookup to Contact)
- Course_Date__c (Date)
- Course_Name__c (Text)
- Status__c (Picklist with values: Not Started, In Progress, Completed)

2. Business Logic
a. Logic for New Training Record Insertion:
When a new Training__c record is inserted, the status on the related Contact object is updated to match the Training__c.Status__c.
b. Logic for Training Status Update:
When the Status__c field on a Training__c record is updated, the status on the related Contact object (Contact.Training_Status__c) is also updated accordingly.
c. Trigger Implementation:
A trigger on the Training__c object is created to manage the above logic, ensuring that the status on the Contact object reflects any changes in the Training__c record.
Trigger Type: After Insert, After Update

3. Lightning Web Component (LWC)
a. Component Overview:
- Component Name: TrainingList
- Functionality:
- Displays a list of training records related to a Contact.
- Allows users to mark a training as “Completed” by clicking a button on the component.
b. Implementation Details:
- Parent Component: The Contact record page will pass the recordId to the LWC.
- Features:
- List of all related Training__c records.
- Option to update the status of a specific training to “Completed.”



4. Batch Apex
a. Batch Job: BatchUpdateTrainingStatus
Functionality:
- The batch job scans all Training__c records where the Status__c is “In Progress” and the Course_Date__c is older than 7 days.
- It updates the status of those records to “Completed.”
b. Batch Class Implementation:

5. Scheduled Apex: Automating The Daily Training Cleanup
The final part of the project was to make sure the system could automatically “clean up” old training records without any manual user action. The business requirement was simple: the batch job BatchUpdateTrainingStatus should run every day at 1 AM and update any training that is still marked as “In Progress” even though the course date is more than seven days old, setting it to “Completed”.
From a Salesforce point of view, the best way to achieve this is to wrap the batch class in a Scheduled Apex job. This ensures the logic runs consistently, even if no one is logged into the system.

Key Takeaways
- ✓Single Source of Truth: Training status is now centrally managed on the Contact object, eliminating external tracking systems.
- ✓Scalability: Batch Apex ensures the system can handle large datasets without hitting governor limits.
- ✓Automation: Scheduled Apex eliminates manual maintenance by running daily cleanup at 1 AM automatically.
- ✓User Experience: Lightning Web Component provides an intuitive interface for users to manage training directly from the Contact record.