//Mixed DML
High Severity Limit Breach

System.DmlException:
UNCOMMITTED_WORK_PENDING

System.DmlException: UNCOMMITTED_WORK_PENDING, Your call requires to be in an active transaction

Mixed DML operations. You tried to insert a User (Setup object) and an Account (non-Setup object) in the same transaction. Salesforce blocks this for data integrity reasons. You didn't know about the Setup/non-Setup separation rule.

3,100 developers search for this error every month. It's one of the most confusing Salesforce errors because the documentation is buried deep.

Jataka catches Mixed DML in real-time
0:52
Watch: Mixed DML detected → Jataka blocks PRLoom Recording

The Rule: Setup vs non-Setup objects

Salesforce enforces a strict separation between Setup objects (User, Profile, PermissionSet) and non-Setup objects (Account, Contact, Opportunity). You cannot perform DML on both types in the same transaction. This protects org security and metadata integrity.

Setup Objects

Cannot mix with non-Setup DML in same transaction:

  • User
  • Profile
  • PermissionSet
  • Role
  • Network
  • Group
  • Queue

Non-Setup Objects

Business data that conflicts with Setup DML:

  • Account
  • Contact
  • Opportunity
  • Lead
  • Case
  • Custom Objects
2 hrs

Average time to debug this confusing error message

0

Static analysis tools that catch this pattern

100%

Prevented when detected before deployment

The Bad Code

This code looks perfectly logical. Create a user, create their account. What could go wrong?

UserOnboardingController.cls❌ Anti-Pattern
// ❌ BAD: Mixed DML operations in same transaction
// Setup objects (User, Profile) mixed with non-Setup (Account)

public void createUserAndAccount() {
    // Setup object DML
    User newUser = new User(
        FirstName = 'John',
        LastName = 'Doe',
        Email = 'john@example.com',
        Username = 'john@example.com',
        ProfileId = '00e...'
    );
    insert newUser; // Setup object
    
    // Non-Setup object DML in same transaction
    Account newAccount = new Account(
        Name = 'Acme Corp'
    );
    insert newAccount; // ❌ CRASH!
    // System.DmlException: UNCOMMITTED_WORK_PENDING
}

Jataka Report Card

Jataka's transaction analyzer detects Setup/non-Setup DML conflicts before execution.

PR #156 Blocked
12 minutes ago

Mixed DML Detected

Transaction contains DML on both Setup (User) and non-Setup (Account) objects. This will cause UNCOMMITTED_WORK_PENDING error.

Line 12: insert newUser;Line 19: insert newAccount;

The Fix

Separate the DML operations into different transactions using async Apex.

UserOnboardingController.cls✓ Fixed
// ✅ GOOD: Separate transactions using async

public void createUserAndAccount() {
    // Setup object DML in current transaction
    User newUser = new User(
        FirstName = 'John',
        LastName = 'Doe',
        Email = 'john@example.com',
        Username = 'john@example.com',
        ProfileId = '00e...'
    );
    insert newUser;
    
    // Non-Setup object DML in async transaction
    Account newAccount = new Account(
        Name = 'Acme Corp'
    );
    
    // Use Future method or Queueable
    createAccountAsync(newAccount);
}

@future
public static void createAccountAsync(Account acc) {
    insert acc; // Separate transaction - no conflict
}

Result: Setup DML completes in main transaction. Non-Setup DML runs in separate async transaction. No conflict. Both operations succeed.

Related Anti-Patterns

Catch confusing errors early

Jataka catches Mixed DML
before the merge.

Book a demo and watch Jataka detect Setup/non-Setup conflicts automatically. Your developers learn the rule without the 2-hour debugging session.