Running Case Assignment Rules From Salesforce Apex

Running Case Assignment Rules From Salesforce Apex

Hi All,

We all know that Case Assignment Rule decides how cases are assigned to users or put into queues. We can create multiple assignment rules, but only one rule can be “active” at a time.

We can trigger assignment rules by simply checking the “Assign using active assignment rules” checkbox under the Optional section of the Case creation page from Standard UI. Or We can set it default true under the “Layout Properties“of the case page layout.

case assignment

But do you know!!! When we are inserting the Case via Apex, the assignment rule will not be triggered  as there is no such field “Assign using active assignment rules” to be checked in the Apex.

DON’T WORRY. Here in this blog you will know how to run assignment rule through apex.

The above piece of code is fetching the active assignment rule of Case and then creating the DMLOptions for the “Assign using active assignment rules” checkbox. Actually Database.DMLOptions class provides advanced information.

So now when the Case is inserted through Apex with the Database.DMLOptions, the assignment rule gets invoked easily.

Happy Salesforce!


Leave a Reply


We're not around right now. But you can send us an email and we'll get back to you, asap.


About Us

Forcetalks is a Salesforce collaboration platform for coders & developers, geeks & nerds, consultants & business heads, admins & architects, managers & marketers and of course the business owners. A community where you can learn from, where you can contribute to. For you. For Salesforce. Read More...

Copyright 2020 Forcetalks. All Right Reserved.

Log in with your credentials


Forgot your details?