Print this page

Cannot Mix DML Operations

Knowledge Article Number 000006037
Description Users may receive the following error when running a trigger that creates a contact every time a user is created:

caused by: System.DmlException: Insert failed. First exception on row 0; first error: MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa): Contact, original object: User: []


 
Resolution

- There are few objects which cannot be used together when performing DML operations, Please check the developer document below more information: 

  sObjects That Cannot Be Used Together in DML Operations : https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dml_non_mix_sobjects.htm

 The workaround for this issue is to use a future method to perform the DML operations





promote demote