Coder Social home page Coder Social logo

MIXED_DML_OPERATION about sfdx-batch-orchestrator HOT 5 OPEN

gluch avatar gluch commented on July 20, 2024
MIXED_DML_OPERATION

from sfdx-batch-orchestrator.

Comments (5)

dschibster avatar dschibster commented on July 20, 2024

Hi! Thanks for using Batch Orchestrator. :) First of all: is that a Batch Class that is processing Users? Usually, mixed DML can be handled by switching Context by designating a separate User to perform the Insert of Users, before / after the rest of the Objects is inserted.

from sfdx-batch-orchestrator.

fentes avatar fentes commented on July 20, 2024

Hey the (test) class is used to (de)activate users at a specific date, So the class itself is just performing DML on User object. But after that, the orchestrator is logging the results which led to the issue.
I assume that the logs are inserted synchronously after the job finished. It it somehow possible to inserting the logs by publishing an event (like nebula does)?

from sfdx-batch-orchestrator.

dschibster avatar dschibster commented on July 20, 2024

Hah, I needed a second to recognize it's Georg! The Name I read in the Email was way less clear than the user name here :D Good to see you on here.
Yes, that can be done by using Enhanced Logging: https://dschibster.github.io/sfdx-batch-orchestrator/logging/
It's important to mark the Checkbox "Enhanced Logging" on the Batch Apex Job Record to true, too.

from sfdx-batch-orchestrator.

gluch avatar gluch commented on July 20, 2024

Hi there :)

Usually we would mark the "Enhanced Logging" checkbox, but this is a test class which is failing and it is pointing us to BatchJobLogger.cls (method: logLegacy).

According to Salesforce it is possible to isolate DML operations on different sObject with the @future annotation.
This prevents the mixed DML error at least on our Sandbox.

I wonder if this change does not screw up anything:

image

Again, with the above change our test class is working fine.

from sfdx-batch-orchestrator.

dschibster avatar dschibster commented on July 20, 2024

I might enable this as a separate method in the future because I would need to test the full implications of it. But good to know. Thanks for the input and best wishes from Japan!

from sfdx-batch-orchestrator.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.