When you create or refresh a Salesforce Sandbox, Salesforce automatically replaces the Organization ID with a new, unique ID for that Sandbox. If a Flow contains a hard-coded 15-digit Organization ID, for example inside a Decision element, that value is automatically overwritten with the new Sandbox's Organization ID.
This is expected Salesforce platform behavior, designed to prevent a Flow from unintentionally processing production-only logic inside a Sandbox environment.
This article explains why a hard-coded Organization ID inside a Flow changes after a Sandbox is created or refreshed, and how to build a formula resource so the Flow can still correctly detect whether it is running in production.
As a Salesforce specification, the Organization ID is replaced with a new unique ID every time a Sandbox is created or refreshed. When a 15-digit Organization ID is written directly into a Flow, for example in a Decision element, Salesforce automatically substitutes the new Sandbox's Organization ID in its place. This is normal behavior and is designed to prevent unintentional processing in the production environment.
To prevent the Organization ID replacement from breaking your logic, and to correctly identify the production environment, create a formula resource in Flow Builder and use it in a Decision element. This method compares only the last 13 characters of the Organization ID, which are not affected by the Sandbox ID replacement.
IF( RIGHT( $Organization.Id , 13)="DXXXXXXXXXXXX" , true, false)This formula checks whether the last 13 characters of the current environment's Organization ID match your production Organization ID. Replace "DXXXXXXXXXXXX" with the last 13 characters of your production Organization ID, excluding the leading "00".
With this formula resource in place, the Flow can correctly determine whether it is currently running in the production environment, even after a Sandbox is created or refreshed and the Organization ID is replaced. This prevents values from being accidentally changed or production-only logic from running inside 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.