Activity Forums Salesforce® Discussions MIXED_DML_OPERATION error in Salesforce?

  • Saurabh

    Member
    April 25, 2017 at 2:01 pm

    Hi Suraj

    You can easily run into this error if you are trying to perform DML on setup and non-setup objects in the same transaction.

    Non-Setup objects are standard objects like Account or any custom object.

    Setup objects are Group1, GroupMember, QueueSObject, User2, UserRole, UserTerritory, Territory, etc..

    For example, you cannot insert an account and then insert a user or a group member in a single transaction.

    Test methods allow for performing mixed DML operations between the sObjects listed earlier and other sObjects if the code that performs the DML operations is enclosed within System.runAs method blocks. This enables you, for example, to create a user with a role and other sObjects in the same test.

    Hoping it may help you:

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos