Given a list of Contact records, attempt to delete them using Database.delete with the allOrNone parameter set to false. This allows partial success - some records may delete successfully while others may fail. Return a Map with two keys: success containing the count of successfully deleted records, and failed containing the count of failed deletions. Handle null or empty input lists by returning zeros for both counts.
Examples:
Input: contacts = [Contact1, Contact2, Contact3] (all deletable)
Output: {'success': 3, 'failed': 0}
Explanation: All 3 contacts were successfully deleted
Input: contacts = null
Output: {'success': 0, 'failed': 0}
Explanation: Null input returns zero counts for both success and failed
Input: contacts = []
Output: {'success': 0, 'failed': 0}
Explanation: Empty list returns zero counts for both success and failed
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.