Salesforce is at its best when it works for you—automating small but impactful business rules that ensure data consistency and improve user productivity. One such use case is auto-updating the Rating field based on the Industry of an Account.
In this blog, we explore a practical Apex trigger that sets the Rating field to “Hot” whenever the Industry is changed to “Media.” Whether the value is selected during Account creation or updated later, this trigger ensures that the Rating always reflects the business priority tied to that industry.
This kind of automation is especially helpful in orgs that rely on the Rating field for segmentation, dashboards, list views, or opportunity prioritization.
🧠 Why Automating Rating Based on Industry Matters
The Rating field in Salesforce is commonly used to indicate how important or engaged an Account is. But if it’s left to users to update manually, it may get skipped, forgotten, or inconsistently applied. When you tie that logic to a clear business rule—like Industry = “Media”—you:
-
Ensure consistent data categorization
-
Help sales and marketing teams instantly identify high-value Accounts
-
Improve the accuracy of pipeline and territory reports
-
Reduce user burden by automating repetitive data updates
-
Support downstream automation that triggers based on Account Rating
This trigger adds just the right amount of intelligence to your record creation and update process—no clicks required.
🔍 What This Blog Covers
-
How to use a before update Apex trigger to automate Account field changes
-
How to compare new and old field values using
Trigger.oldMap
-
How to ensure logic runs during both creation and update
-
Why this business rule improves data quality and visibility
-
How to write clean, scalable code using a trigger handler class
-
Where this type of automation fits in real-world Salesforce orgs
This solution is perfect for teams looking to automate data enrichment based on field values while keeping their codebase light and efficient.
🎯 Real-World Use Cases for This Trigger
-
Media and entertainment sales teams that prioritize certain industries
-
B2B companies using Rating to influence lead scoring or sales rep assignment
-
Customer success teams that tier support levels based on Account rating
-
Marketing teams segmenting campaign lists based on business potential
-
Executives reviewing hot accounts directly from dashboards or reports
This automation ensures that any Account tied to the Media industry is automatically surfaced as a high-priority record across your entire org.
👨💻 Developer & Admin Tips
The logic is written to work in both Account creation and update scenarios, making it reusable and predictable. It checks if:
-
The record is new and
Industry
is “Media”
or -
The existing record’s
Industry
field has been changed to “Media” during an update
If either is true, the Rating
field is set to “Hot” during the before update phase, meaning it will be saved along with the Account without needing additional DML.
This approach keeps your logic efficient, bulk-safe, and highly maintainable.
To ensure accuracy:
-
Test your logic for both insert and update cases
-
Watch out for bulk operations via imports or API integrations
-
Use this structure as a pattern for future industry-to-field mapping use cases
If your org uses other values like “Healthcare” or “Finance” to influence Rating or Priority, this model is fully extensible.
🎥 Watch It in Action – YouTube Playlist Included
We’ve added this use case to the Salesforce Makes Sense YouTube playlist, where you’ll find:
-
Trigger walkthroughs
-
Hands-on coding sessions
-
Explanations of old vs. new value comparison logic
-
Clean handler structure demonstrations
Whether you’re a Salesforce admin leveling up with Apex or a developer refining your trigger logic, this example is a great addition to your toolkit.
Solution:
trigger AccountTrigger on Account (before update) {
if(Trigger.isUpdate){ if(Trigger.isBefore){
AccountTriggerHandler.updateIndustryRating(Trigger.New, Trigger.oldMap);
}
}
}
public class AccountTriggerHandler {
public static void updateIndustryRating(List<Account>
accList,Map<Id,Account> oldMap){ for(Account
acc:accList){ if((oldMap==null &&acc.Industry==’Media’)
|| (acc.Industry==’Media’ && acc.Industry != oldMap.get(acc.Id).Industry)){
acc.Rating=’Hot’;
}
}
}
}