function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
cduncancduncan 

Where do Email Services fall in the Order of Execution?

I noticed that the "Priority" default value specified in an Email-to-Case entry will overwrite values set in a "before" Flow, but it will be overwritten by an "after" Flow. (I have not tested triggers, but I imagine the result is similar.) The documentation at the link below does not specify where Email Services fall in the order of execution, so when does that processing happen?

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_order_of_execution.htm
VinayVinay (Salesforce Developers) 
Hi Cduncan,

It depends on where you are using your email services i.e which component like trigger,wf etc and email might be triggered after post commited logic is completed.

Below is order of execution details.
  • System Validation Rules.
  • Executes record-triggered flows that are configured to run before the record is saved.
  • Executes all before triggers.
  • Custom Validation rules.
  • Executes duplicate rules.
  • Saves the record to the database, but doesn’t commit yet.
  • Executes all after triggers.
  • Executes assignment rules.
  • Executes auto-response rules.
  • Executes workflow rules.
  • Executes escalation rules.
  • If there are workflow field updates, updates the record again.
  • If the record was updated with workflow field updates, fires before and after triggers one more time. Custom validation rules, flows, duplicate rules, processes, and escalation rules are not run again.
  • Executes processes and flows launched via processes and flow trigger workflow actions.
  • Executes entitlement rules.
  • Executes record-triggered flows that are configured to run after the record is saved.
  • If the record contains a roll-up summary field or is part of a cross-object workflow, performs calculations and updates the roll-up summary field in the parent record. Parent record goes through save procedure.
  • If the parent record is updated, and a grandparent record contains a roll-up summary field or is part of a cross-object workflow, performs calculations and updates the roll-up summary field in the grandparent record. Grandparent record goes through save procedure.
  • Executes Criteria Based Sharing evaluation.
  • Commits all DML operations to the database.
  • Executes post-commit logic, such as sending email.
 Please mark as Best Answer if above information was helpful.

Thanks,