I'm trying to update case owner in after insert trigger but assignment rule is running as per order execution, if criteria doesn't match ,default owner from support settings is being set as an owner. When record get created into Salesforce following Order of execution works: System Validation Rules Apex Before Triggers Custom Validation Rules Duplicate Rules Apex After Triggers Assignment Rules
-
You can move the code which updates the case owner from trigger to a future method and call that method from your after insert trigger. So your assignment rule will change to default owner and the future will execute asynchronously from current transaction and change to your desired owner.– Vigneshwaran GFeb 17, 2021 at 7:15
-
@VigneshwaranG Thank you, it worked!– PayAFeb 17, 2021 at 10:25
1 Answer
You can move the code which updates the case owner from trigger to a future method and call that method from your after insert trigger. So your assignment rule will change to default owner and the future will execute asynchronously from current transaction and change to your desired owner.