[SalesForce] Case Assignment Rule not triggering on Case Creation in Communities

I have used a Case Assignment rule which works fine normally on Case creation based upon record types, but when I try to create a case through Community portal using a Community user profile, the case assignment rule is not triggered.

On Case Detail Edit page in the Community portal, I cannot find "Assign using Active assignment rule" checkbox. I tried to follow this article:
http://help.salesforce.com/HTViewSolution?id=000005470

to enable Select by default check box in Page layout but still I dont find the Case assignment rule triggering.

Also the same is not visible in the debug logs.

Am I missing something here?

Any help on this would be highly appreciated.

Thanks!

Best Answer

You can trigger this via a simple trigger on Case .The below code should help you .Since community UI has nothing to do with page layout and you may be inserting via your own custom interface this issue might have occured

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

To automate further you can write a before trigger that adds the DML Options Header

Related Topic