Questions tagged [mixed-dml]
The mixed-dml tag has no usage guidance.
27 questions
0
votes
1
answer
51
views
DMLEXCEPTION NOT BEING CAUGHT
I HAVE WRITTEN THE BELOW CODE BUT IT IS NOT THROWING THE MIXEDDMLEXCEPTION AND I DON'T UNDERSTAND WHY.
public class April22Task2 {
public static void createUserAndAccount()
{
//...
1
vote
1
answer
834
views
Is it possible to create user and assign permission set in same flow?
I am trying to create users and trying to assign permission sets to them using flow.
Since we get MIXED DML error when we try to do both of these tasks in a single transaction, I tried to use the ...
3
votes
1
answer
441
views
Best architecture solution for Mixed DML Exceptions inside a Batch
I am writing an apex Batch
First I am updating a few EmailTemapltes and then I need to write to a custom object.
public void execute(Database.BatchableContext context, List<EmailTemplate> scope) ...
1
vote
1
answer
446
views
Mixed DML occurring even in Finalizer in Queueable
We have a queueable framework where we have an object AsyncRequest__c
Fields Are : ApexClassName__c, Content__c, AttachmentAvailable__c, Status__c etc
So whenever someone wants to enqueue a job they ...
0
votes
2
answers
936
views
HTTP Callout after async DML
I'm trying to do HTTP callout after DML in future method, but I'm getting System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out.
What I'm missing? Is ...
0
votes
1
answer
271
views
Facing Mixed DML operation for apex class
I have written a scheduler for deactivating salesforce users who doesn't logged in for last 90 days. The code is working as expected if I remove exception logging into a salesforce object at line #14. ...
1
vote
1
answer
777
views
DmlException Creating CMS Library/Folders
I have some Apex code written to create a new Account, and then create a new Library (ContentWorkspace) and new Folder (ContentFolder) within that Library to house assets for that Account. It appears ...
0
votes
1
answer
987
views
Setup and NonSetup object insertion in Test Class
we've a factory class method to create sObject:
Class: DataFactory:
public static SObject createSObject(SObject sObj, String defaultClassName, Boolean doInsert) {
SObject retObject = ...
0
votes
1
answer
587
views
Getting mixed DML even in two standard objects "GroupMember" and "ContactShare"
Scenario -> Creation Contact share record and in the same transaction creating GroupMembers for one of groups related to custom object.
Throws -> Insert failed. First exception on row 0; first ...
1
vote
1
answer
338
views
MIXED DML Exception Custom settings + UserPackageLicense
I am trying to update a Custom Setting record and insert an UserPackageLicense record in the same transaction, however I am facing MIXED DML exception.
Why do I face this exception? I thought custom ...
0
votes
1
answer
3k
views
Upsert DML Operation
Consider the below code. I thought the way upsert DML works is that if it sees that there is a new record with matching key (here in this case there is already an account with Name = Acme and ...
0
votes
1
answer
308
views
How to avoid MIXED dml Exception in update operation? [closed]
I got System.DmlException in update operation. Can anyone please check the below code and help me to resolve the exception.
I have tried to solve it for the last two days but I couldn't find a ...
1
vote
1
answer
532
views
MIXED_DML_OPERATION : Can not insert a user record from account trigger even when User Role is null
I am trying to create a community user in an after update trigger of account. I am setting the UserRoleId = null but still am getting MIXED_DML_OPERATION exception. As per documentation:
You can ...
1
vote
1
answer
141
views
Is there a way to know if a setup object has been updated in the current transaction?
We have a custom error logging framework built that currently inserts records to a custom Error Log object. We also have a lot of (chained) Queueables in use because have to update some setup objects -...
0
votes
1
answer
1k
views
Error: MIXED_DML_OPERATION Very Confused
I'm very confused about MIXED_DML_OPERATIONerror. Following test case fails in production but passes in uat.
@IsTest
private class MyControllerTest {
private static final String USERNAME ='test@...
0
votes
0
answers
129
views
Mixed DML causing test classes to fail to to Process builder
I have a Test class which was working fine but after a new process builder was created on user object to update a custom field created on user object, it started failing. In my test class code I am ...
6
votes
1
answer
804
views
Does MIXED_DML_OPERATION behave differently in test methods depending on how you run them: Test Execution vs. Deployments?
We typically validate our source control nightly and run all tests. This is essentially a validate only deployment running all tests against production. All tests pass.
However, if we were to run ...
1
vote
1
answer
1k
views
You have uncommitted work pending. Please commit or rollback before calling out even if we put DML in future method
I know as per documentation, we cannot perform DML and then callouts from apex class.
In my scenario, I have a callout then I am performing a DML which is placed inside a future method and again ...
1
vote
1
answer
522
views
Update email address and profile on SandboxPostCopy MIXED DML OPERATION error
I've been trying to update user emails and profiles after a sandbox is created and using the SandboxPostCopy interface. However I keep running into the below error:
Update failed. First exception ...
1
vote
1
answer
1k
views
Batch method making callout: uncommitted work pending
My app is an SMS lightning component, so in many situations, I'm doing DML updates AND making a callout. I have avoided the "uncommitted work pending" errors by using @future (callout=true) on all the ...
2
votes
1
answer
1k
views
Just-in-Time Provisioning for Communities Mixed DML Error
We are trying to implement Just-in-Time Provisioning for Communities using custom handler class. There are 3 scenarios
When Contact with the provided email (Federation ID) exist in salesforce and ...
11
votes
2
answers
1k
views
Apex method to find out if SObject is a setup object
Regular SObjects and Setup Objects can't be mixed in DML otherwise you'll experience a Mixed Dml Exception.
How can Apex code find out if a given SObjectType is such a setup object?
System.assert(...
2
votes
2
answers
1k
views
MIXED_DML_OPERATION when updating User.Username in a trigger that also updates Contact
I have a Contact trigger that, after update, checks to see if some fields (Email or Team) were changed, and if they were, it updates the fields on the Contact's associated User record. These two ...
6
votes
0
answers
234
views
Why inserting a user object and making callout in a test throws CalloutException in Production?
I stumbled upon strange behavior when executing tests on deployment to production organization. In the test, I first insert a User object, some other objects and then as the last one, a CampaignMember ...
1
vote
1
answer
2k
views
Is a single APEX test case considered a transaction?
I'm getting DML errors when trying to test some triggers:
This error occurred: MIXED_DML_OPERATION: DML operation on setup
object is not permitted after you have updated a non-setup object (or
...
2
votes
2
answers
2k
views
Sudden MIXED_DML_OPERATION errors without code changes
So I have 3 orgs that are basically all on the same codebase. On the production org (the one that gets changed the least) some of the tests are suddenly failing - all with the same error message:
...
1
vote
1
answer
282
views
Mixed DML conflict in unit test involving two queueable jobs
I have a complex Apex trigger that calls two separate queueable jobs - one job inserts Permission Set Assignments, and another job creates and deletes ContactShare records. I am positive that neither ...