function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion 

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

I have seen some forum saying to use @future to get around this, but I'm not sure how to accomplish that

Below is my trigger, it is short and sweet (well at least I think so). Please have a look and let me know how to fix this.


trigger Touch_Imp on User (after insert) {
    Set<String> usercontactid = new Set<String>(); 
    for (User u : {
    if([SELECT COUNT() FROM implementation__c WHERE implementation__c.implementation_contact__c IN :usercontactid]>0){
        Implementation__c[] updateimp = [SELECT id from Implementation__c WHERE implementation__c.implementation_contact__c IN :usercontactid];



I'm not sure if the @future annotation will work in this case (Salesforce doesn't let you modify a setup object like User and another object in the same context), but in order to use the @future annotation you will need to pull your trigger logic into a separate class, and put the @future annotation on the method. Because it's a future you would need to pass in the Ids of the record.




Id[] userIds = new Id[]{};

for (User u : {




if (!userIds.isEmpty()) {

    // new class and method







public class UserImplementation {


   public static void processUsers(Id[] userIds) {




You will have to excuse my ignorance, but I don't understand classes. It is seperate from my trigger?


Also with what you have there aren't you creating the User records after the update to the Imp records?


What I'm trying to accomplish is simply when a user record is created it checks to see if user.contactid is associated with any of the implementations (think of them as cases). If it is then it updates those Implementations.

I'm doing this to try and get my triggers on my Implementations to trigger. Does this make sense? Is there maybe an all around better way to accomplish this?


Also the user record needs to be created before I update the Implementation record as the trigger are causing new sharing rules to be created on the Implementation based upon the User record.