Skip to content

MIXED_DML_OPERATION Errors in tests that create users in some orgs #938

@jongpie

Description

@jongpie

Hi! We have been using a NebulaLogger for a while without any issues. However, when we create a trigger on User that inserts a GroupMember, the LogEntryEventHandler_Tests and LogHandler_Tests fail with a MIXED_DML_OPERATION error. It appears that when a loggerScenarioOwner user is inserted in the test method, it triggers our process that attempts to insert a GroupMember (a setup object) and the test method that tries to insert a LoggerScenario__c (a non-setup object). This results in a DML operation on both setup and non-setup objects in the same transaction.

Here is the list of tests involved and where the similar issue occurs:

- LogEntryEventHandler_Tests.it_should_set_logger_scenario_owner_as_log_owner_when_log_assignment_enabled_via_logger_scenario_rule
- LogHandler_Tests.it_should_set_owner_when_default_configured_with_user_id
- LogHandler_Tests.it_should_set_owner_when_default_configured_with_username

I wanted to know if there are any upcoming adjustments on your side regarding these tests. Thank you in advance for you assitance !

Cc @angelikagalang

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): LoggerScenario__c, original object: GroupMember: []
Class.LogEntryEventHandler_Tests.it_should_set_logger_scenario_owner_as_log_owner_when_log_assignment_enabled_via_logger_scenario_rule: line 653, column 1

Originally posted by @Norema9 in #932

Metadata

Metadata

Assignees

Labels

Type: BugSomething isn't workingtestsRelates to Apex or LWC jest tests

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions