+ Start a Discussion
Sachin_KSachin_K 

Accessing "Assign using active assignment rules" option of case object from trigger

Hi,

 

We have a "Assign using active assignment rules" option at the bottom whenever we create a new case. We can chose a default value for this option from the page layout. Can we also access or set it through a trigger on case object. I tried finding the field name for this field, but got none.

 

Please let me know, if someone knows about this field.

 

Thanks,

Sachin

Best Answer chosen by Admin (Salesforce Developers) 
mike4adaymike4aday

Sachin,

 

Assignment rules for cases and leads are stored in a separate object, "AssignmentRule" -- see:

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_assignmentrule.htm

 

You can assign (or not) a case according to the related, active assignment rule by using the "Database.DMLOptions" object -- see:

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_database_dmloptions.htm

All Answers

mike4adaymike4aday

Sachin,

 

Assignment rules for cases and leads are stored in a separate object, "AssignmentRule" -- see:

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_assignmentrule.htm

 

You can assign (or not) a case according to the related, active assignment rule by using the "Database.DMLOptions" object -- see:

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_database_dmloptions.htm

This was selected as the best answer
Sachin_KSachin_K

Thanks a lot. That was helpful

Balaji BondarBalaji Bondar
trigger TCKCaseAssignment on Case (after insert) {
    //Variable decleration
    List<Case> caseList = new List<Case>();
    User integrationUserObj = new User();
   
    if(Trigger.isAfter && Trigger.isInsert){
        //Fetching the integration user details
        integrationUserObj = [SELECT Id, Name FROM User where Name = 'Balaji Bondar' LIMIT 1];
           
        for (Case caseObj : Trigger.new) {
            if (caseObj.OwnerId  == integrationUserObj.Id) {
                caseList.add(new Case(id = caseObj.id));
            }
        }
   
        Database.DMLOptions dmo = new Database.DMLOptions();
        dmo.assignmentRuleHeader.useDefaultRule = true;
        Database.update(caseList, dmo);
    }
}