2

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!

| improve this question | | | | |
  • You can also use workflow rules if you don't want to use code. Is your community on Napili Template ? – Bob Gali Aug 6 '18 at 6:50
0

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

| improve this answer | | | | |
  • This absolutely make sense and i am having the same issue. However, when the Case will be routed to the Queue then the owner of the Case will change and then how the user would track the Case who has actually created the Case? – Ali Sep 29 '16 at 19:31
0

Apparently, in case of record insertion, this only seems to work with after insert and not with before insert. Here's a way you can do this.

Set<Id> setCaseIds = new Set<Id>();
for(Case eachCase : trigger.new) {
    setCaseIds.add(eachCase.Id);
}
List<Case> lstCaseUpdateOwner = new List<Case>();
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.AssignmentRuleHeader.useDefaultRule = true;
for(Case eachCase : [SELECT Id FROM Case WHERE Id IN: setCaseIds]) {
    eachCase.setOptions(dmo);
    lstCaseUpdateOwner.add(eachCase);
}
update lstCaseUpdateOwner;
| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.