Given an Account ID and a new Industry value, update the Account Industry field. Then update all related Contacts by setting their Department field to match the new Industry. Return the total count of records updated (Account + Contacts). Use Database methods with allOrNone=false for error tolerance.
Examples:
Input: accountId = '001...', newIndustry = 'Technology'
Output: 5
Explanation: 1 Account updated + 4 related Contacts updated = 5 total records
Input: accountId with no contacts, newIndustry = 'Finance'
Output: 1
Explanation: Only the Account is updated, no contacts exist
Input: accountId = null, newIndustry = 'Technology'
Output: 0
Explanation: Null account ID results in zero updates
Apex Code Editor
Welcome to Lightning Challenge!
Create an Account
Sign up to track your progress, earn points, and compete with others. Your solutions will be saved automatically.
Create accountHow It Works
- • Write your solution in the code editor
- • Connect your Salesforce org to test
- • Submit to check if your solution passes
- • Use hints if you get stuck
Contest Alert
🏆 #CodeEveryDay Jan 2026
Contest runs January 1 - 31. Complete challenges to climb the leaderboard!
Points are calculated for challenges completed during the contest period.