I need to evaluate records after their assignment rules have been updated, workflows do not meet this requirement because I need complex apex logic after the record has met the condition.
I believe process builders are also not possible as they are executed before assignment rules.
Assuming the above is correct, I plan on publishing a platform event after commit in a trigger. The platform event would then invoke a process builder to then invoke the apex, but I am unsure as to when a platform event is published when invoked from a trigger.
Given order of execution is:
- Before Flows
- Before Triggers
- Validation Rules
- Duplicate Rules
- After Triggers
- Assignment Rules
- Auto-Response Rules
- Workflow Rules
- If updated via workflow field updates, update and after update triggers ran again.
If I use a publish after commit platform event, will the event be published after the first after triggers or after the workflow rules / second round of after triggers?
The documentation states that after the duplicates rules, but before the first after triggers:
Saves the record to the database, but doesn't commit yet.
I would assume this means the platform even would wait until the last round of workflow rules/after triggers to be published, but it's not clear.