Why are we getting MIXED_DML_OPERATION Exception

MIXED_DML_OPERATION, MIXED DML OPERATION EXCEPTION, MIXED DML OPERATION salesforce, dml exception salesforce,salesforce tutorial, salesforce training chennai, online salesforce training,Why are we getting MIXED_DML_OPERATION Exception

Why are we getting MIXED_DML_OPERATION Exception ?

Because it will occur when you try performing DML operation on a setup object and non-setup object in same transaction,

Following are the setup objects where you can’t perform mixed DML operations in same transaction,

  • FieldPermissions
  • Group

    You can only insert and update a group in a transaction with other sObjects. Other DML operations aren’t allowed.

  • ObjectPermissions
  • PermissionSet
  • PermissionSetAssignment
  • QueueSObject
  • ObjectTerritory2AssignmentRule
  • ObjectTerritory2AssignmentRuleItem
  • RuleTerritory2Association
  • SetupEntityAccess
  • Territory2
  • Territory2Model
  • UserTerritory2Association
  • User

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.

Click Here for Example on avoiding this MIXED_DML_OPERATIONS EXCEPTION

 

Be the first to comment

Leave a Reply

Your email address will not be published.


*