Loading

A Case created through Email-to-Case has a populated ContactId, but its AccountId field is unexpectedly null in the before insert trigger.

Publiceringsdatum: Aug 20, 2025
Beskrivning

Steps to Reproduce : 

1.Set up an Email-to-Case flow in your Salesforce organization.
2.Ensure a Contact record is associated with the email address for the case.
3.Create a before insert trigger on the Case object. For example:

trigger DebugCaseValues on Case (before insert) {\
  for (Case c : Trigger.new) {
    System.debug('##### Case values: ' + c);
  }
}

4.Create a Case by sending an email to your Email-to-Case address.
5.Check the debug logs for trigger execution.
6.Observed Result
The debug logs show that the AccountId field is null in the before insert context.

##### Case values: Case:{Id=null, ..., ContactId=003..., AccountId=null, ...}

 

Lösning

This behavior is working as designed.
Salesforce performs internal post-processing to properly associate the Case with the Account from the related Contact. This process occurs after the record has been committed to the database (i.e., after insert). The AccountId isn't available during the before insert trigger because the platform hasn't yet finalized the relationship between the CaseContact, and Account.

Knowledge-artikelnummer

005132457

 
Laddar
Salesforce Help | Article