Skip to main content
Create a trigger on case that if owner is external community user(profile = customer community user)then the check box "assign using Active assignment rules" should be active.

Thanks

KMK
2 answers
  1. May 3, 2017, 7:21 AM

    trigger CaseAssignment on Case (after insert,after update) {

    //Variable decleration

    List<Case> caseList = new List<Case>();

    User integrationUserObj = new User();

    //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;

    if(Trigger.isAfter && Trigger.isInsert){

    //Fetching the Community User details

    integrationUserObj = [SELECT Id, Name FROM User where Profileid= '00e28000001hb4Y' LIMIT 1];

    for (Case caseObj : Trigger.new) {

    if (caseObj.OwnerId == integrationUserObj.Id) {

    Case newCase = new Case(Status = 'New') ;

    //Setting the DMLOption on Case instance

    newCase.setOptions(dmlOpts);

    caseList.add(newCase);

    }

    }

    Database.update(caseList, dmlOpts);

    }

    }

     
0/9000