You need to sign in to do that
Don't have an account?
Raghu Reddy 35
Test Class 'Mixed DML Error'
Hi Gurus,
I have created an Apex Class which creates a User Account (future method) . This Class is called from Process Builder when a custom object record is created.
Now, I am trying to create a Test Class, but I am getting 'MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa):'
How to get around this ?
Thanks,
Raghu
Now, I am trying to create a test class for this,
Have you already taken a look at this article, which discusses a possible workaround: https://developer.salesforce.com/docs/atlas.en-us.198.0.apexcode.meta/apexcode/apex_dml_non_mix_sobjects_test_methods.htm
All Answers
Have you already taken a look at this article, which discusses a possible workaround: https://developer.salesforce.com/docs/atlas.en-us.198.0.apexcode.meta/apexcode/apex_dml_non_mix_sobjects_test_methods.htm
This link might be helpful to you.
http://www.tgerm.com/2012/04/mixeddmloperation-dml-operation-on.html#more
Regards
Anji reddy
1) https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dml_non_mix_sobjects.htm
2) https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dml_non_mix_sobjects_test_methods.htm
Mixed DML Operations in Apex Class:-
You can perform DML operations on more than one type of sObject in a single class using the following process:
1) Create a method that performs a DML operation on one type of sObject.
2) Create a second method that uses the future annotation to manipulate a second sObject type.
Mixed DML Operations in Test Methods :-
The System.runAs block runs in the current user’s context. It creates a test user with a role and a test account, which is a mixed DML operation.
Using Test.startTest and Test.stopTest to bypass the mixed DML error in a Test Method
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dml_non_mix_sobjects_test_methods.htm
Please let us know if this will help you