Loading

How to Deal with the Behavior of Replacing Hard-Coded Organization IDs in Formulas When Creating or Refreshing a Sandbox

Udgivelsesdato: Dec 11, 2025
Beskrivelse

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.

Løsning

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.

Why the Organization ID Changes

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.

How to Prevent the Organization ID from Being Replaced

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.

  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)
    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".
  5. Click Done.
  6. In a Decision element, configure the outcome to check whether the formula resource equals `{!$GlobalConstant.True}`.

Result

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.

Yderligere ressourcer

Servers and IDs

RIGHT

Vidensartikelnummer

005134850

 
Indlæser
Salesforce Help | Article