I am trying to insert a case in apex and set the owner to a specific user id.

However active assignment rules are rerouting the case.

In apex, how would I disable the use of active assignment rules upon insert as you can on the default case creation.

In the case history I can see the owner is going to the user id I set, but the assignment rule changes it on creation.

activeCase.OwnerId = createCaseOwnerId;
insert activeCase;

enter image description here

1 Answer 1


You have to disable the case assignment while inserting. You can do that using DMLOptions.

Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.useDefaultRule= false;

activeCase.OwnerId = createCaseOwnerId;
insert activeCase;
  • Thanks, I saw this in a trigger example and mistakenly thought it was trigger specific.
    – S.B.
    Apr 2, 2019 at 14:33

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.