This question runs in a pre-configured Salesforce environment - no personal connection required.
Create a method that performs complex DML operations with comprehensive error handling.
Parameters:
accounts(List<Account>): List of Account records to processcontacts(List<Contact>): List of Contact records to process
Returns:
Map<String, Integer>: Map containing success counts for each operation
Requirements:
- Use DML insert operations for both accounts and contacts
- Handle DML exceptions gracefully for each operation
- Return a map with keys: 'accounts_inserted', 'contacts_inserted', 'accounts_failed', 'contacts_failed'
- Handle null inputs by returning appropriate counts
- Use try-catch blocks for each DML operation
Example:
List<Account> accounts = new List<Account>{new Account(Name = 'Test')};
List<Contact> contacts = new List<Contact>{new Contact(FirstName = 'John', LastName = 'Doe')};
Map<String, Integer> result = complexDmlErrorHandling(accounts, contacts);
// Returns: {'accounts_inserted' => 1, 'contacts_inserted' => 1, 'accounts_failed' => 0, 'contacts_failed' => 0}
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.