Loading
Salesforce から送信されるメールは、承認済ドメインからのみとなります続きを読む

Standard Required Fields (e.g., Case Status) Accept Null Values via Apex or API Due to the defaultedOnCreate Metadata Settingg

公開日: May 22, 2026
説明

Some standard required fields in Salesforce — such as the Status field on the Case object — can be set to null when updated via Apex or the Salesforce API, without triggering a validation error. This is unexpected because the fields are marked as required in the Salesforce UI.


The reason this behavior occurs is a metadata-level interaction between two field properties: nillable and defaultedOnCreate.

 

  • nillable: true means the field accepts null values programmatically, even if it is required in the UI.
  • defaultedOnCreate: true means the field receives a default value at record creation time and will never be null after initial insert.

When a field has defaultedOnCreate: true, Salesforce may mark it as nillable: true, because the system guarantees a default value exists at creation. This combination overrides the required constraint at the programmatic level, allowing null values to be set via Apex DML or API calls without throwing an exception.
This behavior differs from fields on objects like Order, where both nillable and defaultedOnCreate are set in a way that strictly enforces the required constraint at all levels

解決策

Why This Behavior Occurs

Salesforce determines whether a field enforces the required constraint programmatically by checking if nillable is set to false. However, this check does not account for fields where defaultedOnCreate is true. When a field has a default value assigned at creation, Salesforce may mark it as nillable: true, knowing it will always have a value after initial record creation. This means some standard required fields (such as Case Status) allow null values via Apex or API without throwing an exception, even though they appear required in the UI.

How to Inspect Field Properties Using the Salesforce REST API

To check the nillable and defaultedOnCreate properties of a field, use the Salesforce REST API Describe endpoint for the object:


GET /services/data/vXX.X/sobjects/ObjectName/describe


In the JSON response, locate the field definition and review the values for "nillable" and "defaultedOnCreate". If both are true, the field may accept null values via Apex or API despite being required in the UI. If nillable is false, the field enforces the required constraint programmatically.

ナレッジ記事番号

005225085

 
読み込み中
Salesforce Help | Article