Learn why the Organization ID in Flow formulas changes in a Sandbox. Use a formula resource to prevent this replacement and correctly identify the environment.
As a Salesforce specification, the Organization ID is changed to a new unique ID each time a Sandbox is created or refreshed.
When this happens, 15-digit Organization ID written directly in a Flow's decision element, for example, is automatically replaced with the Organization ID of the new Sandbox.
This is normal behavior, designed to prevent unintentional processing in the Production environment.
To prevent the Organization ID replacement and correctly identify the Production environment, create a formula resource and use it in a Decision element. This method compares the last 13 characters of the ID.
1.In Flow Builder, click [New Resource] in the Toolbox.
2.For Resource Type, select [Formula] and enter an API Name.
3.For Data Type, select [Boolean].
4.In the [Formula] field, enter the following formula:
==
IF( RIGHT( $Organization.Id , 13)="DXXXXXXXXXXXX" , true, false)
==
Note: Replace "DXXXXXXXXXXXX" with the last 13 characters of your Production Organization ID (excluding the leading "00").
5.Click [Done].
6.In a Decision element, configure the outcome to check if the formula resource is {!$GlobalConstant.True}.
This setting allows the flow to correctly determine whether the environment it is currently running in is the production environment, and prevents values from being accidentally changed when creating a 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.