+ Start a Discussion
Tim May 12Tim May 12 

first error: MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa): Case, original object: S2XUserMap: []

Hello,

Before starting, I know about DML operations and the order they should be performed in for test cases. Please do not comment on that. These test cases succeed and have been succeeding in partial and production for over 2 years. 

We recently enabled the Office 365 Outlook Configuration and we started getting test cases failing in production.

Here is the error that we see:
first error: MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa): Case, original object: S2XUserMap: []

We saw this was once an issue in Winter'18 but has (apparently) been fixed.

https://trailblazer.salesforce.com/issues_view?id=a1p3A0000008gVyQAI

I think my next step is to go through all of the test cases and use a user and profile that is not mapped in the Outlook Office 365 config. These would be used in just the test case execution. 

Our current test cases were written by persona/profile so that we would test specific areas that our code needed to run against. We do create users and use System.runAs() for that test. 

Does anyone else have this happening to them also? Or did this happen to anyone else?
Herish SurendranHerish Surendran
Hi Tim. Mixed dml error occurs when the DML operations are performed on Setup Object and sObjects in same transaction. In order to avoid this error we perform these DML operations in seperate transaction. For example perform DML operation on user in class A and calling future method class B from class A . Class B containg DML operation on Account. To get to know more on this refer the link https://www.forcetalks.com/salesforce-topic/what-is-mixed-dml-operation-error-and-how-to-avoid/#:~:text=(execute%20immediately).-,if%20we%20perform%20DML%20operation%20on%20standard%2Fcustom%20object%20records,is%20decorated%20with%20%40future%20annotation.
Tim May 12Tim May 12
I completely agree with your above statement, however, the test case works without an Outlook Sync config and does not work with an Outlook Sync config. Also nowhere in the code am I making an S2XUserMap user object. So it is not the code, but rather a config issue.