This question runs in a pre-configured Salesforce environment - no personal connection required.
Write a method that updates all Accounts with a specific old industry value to a new industry value. The method should return the count of records successfully updated.
The method should:
- Accept two parameters: the old industry value to find and the new industry value to set
- Query for all Accounts with the specified old industry
- Update those Accounts with the new industry value
- Use Database.update with allOrNone set to false for error handling
- Return the count of successfully updated records
Method Signature
public static Integer updateAccountIndustries(String oldIndustry, String newIndustry)
Examples
Example 1:
Input: oldIndustry = "Technology", newIndustry = "Software"
Output: 5
Explanation: 5 accounts with Industry "Technology" were updated to "Software"
Example 2:
Input: oldIndustry = "Retail", newIndustry = "E-commerce"
Output: 0
Explanation: No accounts with Industry "Retail" were found
Example 3:
Input: oldIndustry = "Manufacturing", newIndustry = "Industrial"
Output: 3
Explanation: 3 accounts with Industry "Manufacturing" were updated to "Industrial"
Apex Code Editor
Welcome to Lightning Challenge!
How It Works
- • Write your solution in the code editor
- • This challenge runs without connecting your own org
- • Submit to check if your solution passes
- • Use hints if you get stuck
Contest Alert
🏆 #CodeEveryDay July 2026
Contest runs July 1 - 31. Complete challenges to climb the leaderboard!
Only the 31 daily challenges shown during this contest count toward points. Earlier dailies don't carry over.