Keeping track of changes to critical fields like phone numbers is essential for maintaining data transparency and operational awareness within your Salesforce org. Instead of relying on memory, scattered notes, or external audits, you can build simple, scalable automation that makes these changes visible—right where your users need them.
In this blog, we explore a practical and clean implementation of a before-update Apex trigger on the Account object. This trigger monitors the Phone
field, and if the value is changed, it logs the update directly into the Account’s Description
field. The log includes both the old and new phone numbers, giving users instant visibility into what changed.
Whether you’re running a sales-driven team or managing client accounts across departments, this kind of automation ensures quick context, fewer surprises, and improved record history clarity—without requiring extra clicks or tools.
🧠 Why This Trigger Is Useful
In many business environments, the phone number is a key contact channel. When it changes, the team needs to know—immediately and clearly. But most users don’t have access to field history tracking, and even if they do, it’s buried a few clicks deep. With this trigger:
-
Your team gets real-time visibility into phone updates
-
Every change is recorded right in the Account’s Description field
-
Users can quickly refer to previous values for reference or backtracking
-
You support cleaner communication handoffs and internal collaboration
This is a simple way to build transparency into your CRM process without relying on external tools or large-scale data models.
🔍 What This Blog Covers
-
How to write a before update Apex trigger for the Account object
-
How to compare the old and new values of a specific field
-
How to dynamically write field changes into the
Description
field -
Why this automation improves data visibility in real time
-
How to use a trigger handler class for clean code and logic separation
-
Where this pattern fits into your org’s broader data management strategy
This solution is perfect for Salesforce teams that want clear audit-style logging, directly in the record, with minimal effort.
🎯 Real-World Use Cases for This Trigger
-
Sales teams needing visibility into changing contact details
-
Customer support agents confirming contact info during escalation
-
Account managers referencing previous values for client conversations
-
Admin teams looking to build lightweight audit logs without enabling field history
-
Consulting orgs standardizing handoffs between teams and reps
This trigger is especially useful in orgs that need to preserve clarity on critical fields without relying solely on Setup-based field tracking.
👨💻 Developer & Admin Tips
The trigger uses Trigger.oldMap
to compare the current and previous Phone
values. When a difference is detected, the new value is written into the Description
field in the following format:
“Phone is updated! Old Value: [old phone] & New Value: [new phone]”
It runs in the before update context, so no DML operation is required to save the new Description value. The logic is written using a handler class for better scalability and testing.
This setup is bulk-safe and designed for use in production environments.
Be sure your Description
field is not already used for other critical data. If it is, you can consider creating a custom text field (e.g., Phone Change Log
) using the same pattern.
🎥 Learn By Doing – YouTube Playlist Available
This trigger is featured in the Salesforce Makes Sense YouTube playlist, where you’ll see a full walkthrough of:
-
Trigger setup and logic
-
How the
oldMap
comparison works -
A step-by-step breakdown of the handler method
-
Testing the result in your org
Whether you’re a beginner trying to understand field-level logic or an intermediate dev looking to improve your automation patterns, this example is a must-have in your trigger library.
Solution:
trigger AccountTrigger on Account (before update) {
if(Trigger.isUpdate){ if(Trigger.isBefore){
AccountTriggerHandler.updateDescription(Trigger.New, Trigger.oldMap);
}
}
}
public class AccountTriggerHandler {
public static void updateDescription(List<Account> accList,Map<Id,Account> oldMap){
for(Account acc:accList){
if(acc.Phone!=oldMap.get(acc.Id).Phone){
acc.Description=’Phone is updated! Old Value :
‘+oldMap.get(acc.Id).Phone+’ & New Value :
‘+acc.Phone;
}
}
}
}