Case assignment rules allow you to automatically route Cases to the appropriate users or queues. A case assignment rule consists of multiple rule entries that define the conditions and order for assigning cases. You can create multiple rules (for example, a Standard rule and a Holiday rule), but only one rule can be "active" at a time.
For information on running a case assignment rule from a Trigger, see below.
From a standard UI, a user can trigger assignment rules by simply checking the "Assign using active assignment rules" checkbox under the Optional section. The problem arises when your app needs to insert the Case from Apex and wants to trigger assignment rules. Using this script, a Case will be inserted but assignment rules will not be triggered as there is no such field "Assign using active assignment rules" on Case.
//Instance of case Case newCase = new Case(Status = 'New') ; //Inserting a Case insert newCase ;
Running Case Assignment Rules from Apex
A solution is using Database.DMLOptions. The Database.DMLOptions class can provide extra information during a transaction, like specifying the truncation behavior of fields or assignment rule information. For example, the script below is fetching the assignment rules from Case and then creating the DMLOptions for the "Assign using active assignment rules" checkbox.
//Fetching the assignment rules on case AssignmentRule AR = new AssignmentRule(); AR = [select id from AssignmentRule where SobjectType = 'Case' and Active = true limit 1]; //Creating the DMLOptions for "Assign using active assignment rules" checkbox Database.DMLOptions dmlOpts = new Database.DMLOptions(); dmlOpts.assignmentRuleHeader.assignmentRuleId= AR.id; Case newCase = new Case(Status = 'New') ; //Setting the DMLOption on Case instance newCase.setOptions(dmlOpts); insert newCase ;
Now when the Case is inserted using this script, the assignment rules get triggered.
How to Trigger Assignment Rules in a Flow
Assignment Rule Does Not Fire on Cases Created Through Email-to-Case
Why Assignment Rule Triggered Even After the Assignment Rule is Deactivated or Removed
000387623

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.