Newer Version Available
sObjects That Cannot Be Used Together in DML Operations
- FieldPermissions
- Group
You can only insert and update a group in a transaction with other sObjects. Other DML operations aren’t allowed.
- GroupMember API
- ObjectPermissions
- PermissionSet
- PermissionSetAssignment
- QueueSObject
- ObjectTerritory2AssignmentRule
- ObjectTerritory2AssignmentRuleItem
- RuleTerritory2Association
- SetupEntityAccess
- Territory2
- Territory2Model
- UserTerritory2Association
- User
You can insert a user in a transaction with other sObjects in Apex code saved using Salesforce API version 14.0 and earlier.
You can insert a user in a transaction with other sObjects in Apex code saved using Salesforce API version 15.0 and later if UserRoleId is specified as null.
You can update a user in a transaction with other sObjects in Apex code saved using Salesforce API version 14.0 and earlier
You can update a user in a transaction with other sObjects in Apex code saved using Salesforce API version 15.0 and later if the user isn’t included in an Lightning Sync configuration (either active or inactive) and the following fields are not updated:- UserRoleId
- IsActive
- ForecastEnabled
- IsPortalEnabled
- Username
- ProfileId
- UserRole
- UserTerritory
- Territory
- Custom settings in Apex code saved using Salesforce API version 17.0 and earlier.
If you're using a Visualforce page with a custom controller, you can't mix sObject types with any of these special sObjects within a single request or action. However, you can perform DML operations on these different types of sObjects in subsequent requests. For example, you can create an account with a save button, and then create a user with a non-null role with a submit button.
- Create a method that performs a DML operation on one type of sObject.
- Create a second method that uses the future annotation to manipulate a second sObject type.
This process is demonstrated in the example in the next section.
Example: Using a Future Method to Perform Mixed DML Operations
This example shows how to perform mixed DML operations by using a future method to perform a DML operation on the User object.