Salesforceの自動採番項目は参照のみの項目であり、内部オブジェクト ID に依存しない一意な ID を提供します。
自動採番項目は、レコード作成時に一意の番号を割り当てますが、仕様上、番号が連続することは保証されていません。入力規則エラーやApexテスト、レコード削除などが原因で欠番が発生する場合があります。本記事では、欠番の主な原因とその詳細について説明します。
欠番は、レコードを保存するトランザクションが完了する前に番号が割り当てられ、その後の処理でレコードの作成が失敗した場合に発生します。
代表的な原因は以下の通りです。
・入力規則や必須入力項目エラーではじかれた場合
※ 必須入力のエラーは内部ロジック上、連番を確保した後に評価されるため連番が飛ぶことになります。
・ Apex のテストメソッドが走った場合 (Apex テストのオプションで「独立した自動採番順序」が無い場合)
・ レコードが削除された場合
・ タイムアウト等の内部的なエラーが発生してロールバックが発生し、レコードが作成されなかった場合
・ 自動採番項目のカウンターがリセットされた場合(カスタムオブジェクトの場合のみ)
000386388

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.