You need to sign in to do that
Don't have an account?
Smita Hodiggeri
Stop Case assignment rule from running when case is created with particular field value
Hi Community,
I am working on a requirement where in I don't want Case assignment rule to run which is changing the case owner.The condition being if there is a value in a particular field (Old case number field which means this case is actually getting unarchived). This is basically a scenario of unarchiving(using ob archiver tool ) where in, upon unarchiving we are loosing original case owner as case assignment rules are running again.
Any ideas on how to implement this?
My ultimate intention is to preserve case owner. Have the same owner assigned to case as it was before archiving.
I read a post which says implement this in future method. I would prefer any non code/low code ways to do this.
https://salesforce.stackexchange.com/questions/186702/turn-off-case-assignment-rules
Would a after insert trigger help?
Thanks in advance,
Smita
I am working on a requirement where in I don't want Case assignment rule to run which is changing the case owner.The condition being if there is a value in a particular field (Old case number field which means this case is actually getting unarchived). This is basically a scenario of unarchiving(using ob archiver tool ) where in, upon unarchiving we are loosing original case owner as case assignment rules are running again.
Any ideas on how to implement this?
My ultimate intention is to preserve case owner. Have the same owner assigned to case as it was before archiving.
I read a post which says implement this in future method. I would prefer any non code/low code ways to do this.
https://salesforce.stackexchange.com/questions/186702/turn-off-case-assignment-rules
Would a after insert trigger help?
Thanks in advance,
Smita
If you prefer to use Code, you can write an after insert trigger to update the Owner ID field with the existing owner ID when the Old Case Number field has a value.
Here's an example of how the trigger code might look: In this trigger, we are checking if the Old Case Number field is not null and then updating the Owner ID field with the value from the Old Owner ID field.
Hope this helps !
Thank you.
My Udpated code.
trigger preserveCaseOwner on Case (before insert) {
List<Id> caseIds = new List<Id>();
for(Case c : Trigger.new){
if(c.original_number__c != null){
c.Old_Owner_Id__c =c.OwnerId;
caseIds.add(c.Id);
}
}
List<Case> casesToUpdate = [SELECT Id, OwnerId, Old_Owner_Id__c FROM Case WHERE Id IN :caseIds];
for(Case c : casesToUpdate){
c.OwnerId = c.Old_Owner_Id__c;
}
update casesToUpdate;
}