I have cases created through email to case and assigned using active assignment rule. In some criteria , I need to assign the case to the specific owner and want to skip the assignment rule in those cases. I have below method and I call it in the Before update event of the case.
private void updateQualifiedCase() {
if(!qualifiedEmailCase.isEmpty() && !mapAccountIdOwnerId.isEmpty()){
// system.debug('#####'+qualifiedEmailCase);
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.useDefaultRule= false;
for(case c : qualifiedEmailCase){
if(mapAccountIdOwnerId.containsKey(c.AccountId)) {
system.debug('Hello11');
c.OwnerId = mapAccountIdOwnerId.get(c.AccountId);
c.setOptions(dmo);
}
} }
Here , I am trying to skip the assignment rule by using - dmo.assignmentRuleHeader.useDefaultRule= false; . However, I see assignment rule still fires and updates the owner back as per the assignment rule. Is there any other way, Database.DMLOptions work?
Alternatively , there is another way I can skip assignment rule using a flag and set that flag after assigning the owner id. However, this approach would require an extra field and update of so many rule criteria