この記事では、フローの数式に記述した本番組織の ID が Sandbox 作成時に自動で置換される事象の概要と、数式リソースを用いてこの事象を回避する方法について説明します。
Salesforce の仕様として、Sandbox を作成または更新するたびに組織 ID は一意の新しいものに変更されます。
その際、フローの決定要素などに直接記述された 15 桁の組織 ID は、新しい Sandbox の組織 ID に自動で置換されます。
これは、意図せず本番環境への処理が実行されることを防ぐための正常な動作です。
組織 ID が置換される動作を回避し、本番環境と Sandbox 環境を数式で正しく判定するには、以下の手順で数式リソースを作成し、フローの決定要素で利用します。
この方法では、ID の先頭 2 桁を削除した 13 桁の文字列を比較することで、自動置換を回避します。
<設定手順>
1.Flow Builder で、画面左側の [ツールボックス] から [新規リソース] をクリックします。
2.[リソース種別] で [数式] を選択し、任意の [API 参照名] を入力します
3. [データ型] で [Boolean] を選択します。
4. [数式] 項目に、以下の数式を入力します。
(例)
IF( RIGHT( $Organization.Id , 13)="DXXXXXXXXXXXX" , true, false)
※ DXXXXXXXXXXXX の部分は、ご自身の 本番環境の組織 ID の先頭 00 を除いた 13 桁の文字列に置き換えてください。
5.[完了] をクリックします。
6. フロー内の [決定] 要素で、この数式リソースの結果が true (グローバル定数 {!$GlobalConstant.True}) と等しいかどうかを判定する条件を設定します。
上記設定により、フローは現在実行されている環境が本番環境であるかどうかを正しく判定できるようになり、Sandbox 作成時に値が意図せず変更されることを防ぎます。
005134850

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.