Sometimes you might have a scenario to Assign Cases to a Closed queue when the status of a Case is Closed and you are using the native Case Save and Close button to capture certain details and close the case.
You will find that Salesforce Assignment Rule does not trigger from this page.
Solution
The Save and Close button on a case launches a different page layout than the Case. The page layout cannot be manipulated.
In a traditional Case form, the page Layout properties button allows you to set a checkbox called
Case Assignment Checkbox --default to true. When this option is set to true, Assignment Manager kicks in as soon as you save the Case.
However, on the Save and Close page layout, this option is not available to be set.
You have to write some trigger code as follows:
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.useDefaultRule = true;
dmo.EmailHeader.triggerUserEmail = true;
List<RecordType> RT = [select Id,Name from RecordType where Name='xxx' LIMIT 1];
system.debug('Size' + ' ' + RT.size() );
for(Case cs : cases){
cs.setOptions(dmo);
}
</,,,,,update case....
The above code will work for other scenarios as well where the Assignment rule manager does not kick in. Mind you, I am not advocating code as a replacement for the Assignment Rule but simply saying that under certain scenarios Salesforce does not trigger the Assignment Manager at all and that is where the above code comes in handy.
You will find that Salesforce Assignment Rule does not trigger from this page.
Solution
The Save and Close button on a case launches a different page layout than the Case. The page layout cannot be manipulated.
In a traditional Case form, the page Layout properties button allows you to set a checkbox called
Case Assignment Checkbox --default to true. When this option is set to true, Assignment Manager kicks in as soon as you save the Case.
However, on the Save and Close page layout, this option is not available to be set.
You have to write some trigger code as follows:
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.useDefaultRule = true;
dmo.EmailHeader.triggerUserEmail = true;
List<RecordType> RT = [select Id,Name from RecordType where Name='xxx' LIMIT 1];
system.debug('Size' + ' ' + RT.size() );
for(Case cs : cases){
cs.setOptions(dmo);
}
</,,,,,update case....
The above code will work for other scenarios as well where the Assignment rule manager does not kick in. Mind you, I am not advocating code as a replacement for the Assignment Rule but simply saying that under certain scenarios Salesforce does not trigger the Assignment Manager at all and that is where the above code comes in handy.
No comments:
Post a Comment