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
orikkerorikker 

case active assignment rules

Does anyone know how to access checkbox through apex or how to enable it so when you create case through apex case uses active assignment rules? 

Best Answer chosen by Admin (Salesforce Developers) 
hisrinuhisrinu

You can use the database methods for this, something like below in your apex code

 

 

database.DMLOptions dmo = new database.DMLOptions();
dmo.AssignmentRuleHeader.UseDefaultRule= true;
Lead l = new Lead(company='ABC', lastname='Smith');
l.setOptions(dmo);
insert l;

 

 

All Answers

hisrinuhisrinu

You can use the database methods for this, something like below in your apex code

 

 

database.DMLOptions dmo = new database.DMLOptions();
dmo.AssignmentRuleHeader.UseDefaultRule= true;
Lead l = new Lead(company='ABC', lastname='Smith');
l.setOptions(dmo);
insert l;

 

 

This was selected as the best answer
orikkerorikker

Awesome. Worked like a charm :)