When a Case record is created in Salesforce — either manually from a Contact record's related list, or via Email-to-Case — developers may observe that the AccountId field is null in Before Insert or Before Update Apex trigger events, even when both a Contact and its related Account are assigned to the Case. This behavior occurs specifically for non-administrator users when the Account field on the Case page layout or field-level security is set to Read-Only.
When a Standard User creates a Case from a Contact's related list with the Account field set to Read-Only, the AccountId is not populated in Trigger.new during the Before Insert event. System Administrators are not affected because they have full field visibility. The AccountId is correctly populated just before the After Trigger events in the order of execution, once the record is saved and the Contact-Account relationship is resolved.
This behavior is considered working as designed. Because the Account field is Read-Only for the Standard User (as determined by field-level security or the page layout), the AccountId is resolved from the database via the Contact record's relationship — a process that occurs after the Before Trigger events. During the Before Insert trigger, the AccountId has not yet been populated for users without edit access to the Account field.
Choose one of the following workarounds based on your implementation requirements:
Option 1: Make the Account Field Editable Make the Account field on the Case object editable for non-administrator users by updating both the field-level security settings and the Case page layout. This allows Salesforce to populate AccountId in the Before Insert trigger.
Option 2: Move Trigger Logic to After Trigger Context Move the trigger logic that depends on AccountId into the After Insert or After Update trigger context. In the After trigger context, AccountId is fully populated and accessible for all user profiles.
Option 3: Query the AccountId in the Before Insert Trigger In the Before Insert trigger, programmatically retrieve the AccountId by querying the Contact record using the ContactId from Trigger.new. Assign the Contact's AccountId to the Case's AccountId field within the trigger.
Note: the query approach requires a SOQL query per trigger invocation — ensure you are following bulkification best practices.
000387008

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.