I have cases created through email to case and assigned using active assignment rule. In some criteria , I need to assign the case to the specific owner and want to skip the assignment rule in those cases. I have below method and I call it in the Before update event of the case.

private void updateQualifiedCase() {
      if(!qualifiedEmailCase.isEmpty() && !mapAccountIdOwnerId.isEmpty()){
      //  system.debug('#####'+qualifiedEmailCase);
       Database.DMLOptions dmo = new Database.DMLOptions();
       dmo.assignmentRuleHeader.useDefaultRule= false;
        for(case c : qualifiedEmailCase){
            if(mapAccountIdOwnerId.containsKey(c.AccountId)) {
                c.OwnerId = mapAccountIdOwnerId.get(c.AccountId);
        } }

Here , I am trying to skip the assignment rule by using - dmo.assignmentRuleHeader.useDefaultRule= false; . However, I see assignment rule still fires and updates the owner back as per the assignment rule. Is there any other way, Database.DMLOptions work?

Alternatively , there is another way I can skip assignment rule using a flag and set that flag after assigning the owner id. However, this approach would require an extra field and update of so many rule criteria

  • see salesforce.stackexchange.com/a/307786/2602 for how this is done with Leads; solution applies here as well
    – cropredy
    May 30, 2020 at 20:21
  • I don't want to create an additional field and update all the rule criteria with this field. Is it something doable using database.DMLOptiobs May 30, 2020 at 20:49
  • 1
    the assignment rules will AUTOMATICALLY run on Email-to-Case; so - you don't get a chance to disable them in the triggers. My solution only requires adding a single rule at the top of the assignment rules; not modifying every rule
    – cropredy
    May 30, 2020 at 21:09

1 Answer 1


The settings are applied before the transaction starts; you can't modify those settings during a trigger. To fix it easily, create a custom field as you described, set it in the before-insert trigger, and then you can create a single rule entry like:

Skip Assignment equals True

And the Owner would be set to:

Keep Owner

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.