Monday, 14 April 2014

MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object

Hi

 We cannot perform DML operation on setup and nonsetup Objects in salesforce.

Example for Non-setupObject -  standard object like Account,contact etc and any custom object.

Example for setObject -

Group
Group Member
Field Permission
Object Permissions
Permissionset
Permissionset Assignment
Queue sObject
SetupEntityAccess
User
UserRole
UserTerritory
Territory


If you are using a Visualforce page with a custom controller, you can only perform DML operations on a single type of sObject within a single request or action. However, you can perform DML operations on different types of sObjects in subsequent requests, for example, you can create an account with a save button, then create a user with a submit button.
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.

For More information please refer the below link.

http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_dml_non_mix_sobjects.htm?SearchType=Stem

2 comments:

  1. Hi,

    How to Create a Permission Set using Apex DML and assign to the user in salesforce.

    please help me.........

    ReplyDelete
  2. Hi Mahesh

    see the below link,

    https://developer.salesforce.com/forums/ForumsMain?id=906F000000090FOIAY

    this might be helpful for you.

    Thanks

    ReplyDelete