# Search and Substitute

> **Audience:** Org Administrators only – general users don’t see these controls.

***

## Why Use Search & Substitute? <a href="#overview" id="overview"></a>

When you move metadata between environments, small but critical differences can break deployments:

* Hard-coded URLs that point to Production instead of Sandbox.
* Object-level permissions that should exist only in lower tiers.
* Label values that need slight tweaks per org.

**Search & Substitute** lets you define *rules* that automatically find and replace text inside selected metadata *before* the deployment or commit occurs. The rules run when you:

* Deploy sandbox → sandbox
* Deploy sandbox → Version Control
* Commit Version Control → sandbox (CI jobs)

That means fewer manual edits, fewer post-deployment fixes, and more predictable pipelines.

***

## Creating a Rule <a href="#procedure" id="procedure"></a>

1. Log in to ARM.
2. Go to **Settings › Search and Substitute**.<br>

   <figure><img src="https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2FZBxv2lL8XZVsVQV18fO9%2Fimage.png?alt=media&#x26;token=75f89b2f-5488-4646-92f5-3969290513b4" alt="" width="231"><figcaption></figcaption></figure>
3. Click **Create Rule**.<br>

   <figure><img src="https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2FEB581sBLYvqrQJnBzWbL%2Fimage.png?alt=media&#x26;token=0edecfcb-f6be-4c59-b0ce-713098a9d84b" alt=""><figcaption></figcaption></figure>

Each rule has a **label** plus one or more **parameters**.

***

### Rule Parameters Explained <a href="#rule-parameters" id="rule-parameters"></a>

<figure><img src="https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2F9UXMaWwzkyLVPoRYrmvy%2Fimage.png?alt=media&#x26;token=82bd57b7-582b-4990-b065-4933f0c3ccc3" alt="" width="563"><figcaption></figcaption></figure>

| #     | Field             | Purpose                                                                                  |
| ----- | ----------------- | ---------------------------------------------------------------------------------------- |
| **1** | **Metadata Type** | Choose a metadata type – *or an individual member* – where the replacement should occur. |
| **2** | **Sub Element**   | The XML path / JSON key holding the text you want to change.                             |
| **3** | **Criteria**      | The exact string (or pattern) to search for.                                             |
| **4** | **Substitute**    | The replacement value.                                                                   |

Click **+** to add up to **5** parameter sets per rule. Duplicate rows are not allowed.

#### Supported Metadata Types

`AutoResponseRule`, `CustomLabel`, `CustomMetadata`, `CustomObject`, `CustomSite`, `Dashboard`, `DashboardFolderShare`, `Network`, `NamedCredential`, `PermissionSet`, `Portal`, `Queue`, `RemoteSiteSettings`, `Report`, `ReportFolderShare`, `SamlSsoConfig`, `SharingCriteriaRule`, `SharingOwnerRule`, `Workflow`

> **Tip:** Combining Search & Substitute with **CI Job** deployment settings lets you adjust the same package differently for each target org.

***

### Example <a href="#example" id="example"></a>

Need to change an invoice number format in one org only? Create a rule like this:

* **Metadata Type:** `CustomObject › Invoice__c`
* **Sub Element:** `Fields.displayFormat`
* **Criteria:** `a-{000}`
* **Substitute:** `a-{001}`

<figure><img src="https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2F2Vc7IkCobdoXwUKlYtEa%2Fimage.png?alt=media&#x26;token=a1e051b4-81fc-4866-a0ae-e87e992e861f" alt="Example rule that changes displayFormat from a-{000} to a-{001} for a CustomObject"><figcaption></figcaption></figure>

Click **Save** to store the rule. It appears in the list with **Edit**, **Delete**, and **Clone** icons.\ <br>

<figure><img src="https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2FnUdfJiuwSAC6VfXXddxP%2FScreenshot%202025-08-16%20at%209.48.02%E2%80%AFPM.png?alt=media&#x26;token=b0199a7e-4aa2-41ec-826b-954195a0baa1" alt=""><figcaption></figcaption></figure>

***

## Using a Rule in Deployments & Commits <a href="#whats-next" id="whats-next"></a>

### Sandbox → Sandbox Deployment <a href="#deploying-the-changes-to-a-sandbox-with-a-new-rule-assigned" id="deploying-the-changes-to-a-sandbox-with-a-new-rule-assigned"></a>

On the **Deployment Settings** screen:

1. Open **Apply Search and Substitute Rules**.
2. Move rules to **Selected** with ![](https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2FXcbiSziXo3ogsGrKjW8u%2Fimage.png?alt=media\&token=5eb439e1-0910-4041-804b-15ac09a6e39b) / ![](https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2FizcWgYMQ7Vn13n3av0gT%2Fimage.png?alt=media\&token=3cbf4ac2-1607-4719-b4d5-7563eb81f5ea).
3. Use the arrows to order execution (top rule runs first).

<figure><img src="https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2FknbaJV86Y1UPjHhM5hA2%2Fimage.png?alt=media&#x26;token=94b77acb-c341-4cab-a450-cc7f381f30a6" alt="Deployment Settings with Search and Substitute rules selected"><figcaption></figcaption></figure>

### Commit to Version Control <a href="#committing-the-changes-from-one-salesforce-org-to-a-version-control-branch-with-new-rules-assigned" id="committing-the-changes-from-one-salesforce-org-to-a-version-control-branch-with-new-rules-assigned"></a>

During **Commit** or **Submit for Validation**, pick your rule under **Search and Substitute**.\ <br>

<figure><img src="https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2FVfKGNt1VvUV56GM4JUEt%2FScreenshot%202025-08-16%20at%209.52.53%E2%80%AFPM.png?alt=media&#x26;token=7f539f46-beb6-4af7-9a53-63513fd8881d" alt="" width="563"><figcaption></figcaption></figure>

### CI Job <a href="#performing-ci-job-with-new-rule-assigned" id="performing-ci-job-with-new-rule-assigned"></a>

When creating a **CI Job**, expand the **Deploy** section and choose the rule<br>

<figure><img src="https://1912836914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9vAxMuDrkUkB4OXlH9CL%2Fuploads%2FUKXEUVf1REzSumyyEk9P%2FScreenshot%202025-08-16%20at%209.50.42%E2%80%AFPM.png?alt=media&#x26;token=8b505fed-1dd7-40da-83f4-1997747c2515" alt="" width="563"><figcaption></figcaption></figure>

***

## Best Practices

* **Granularity first** – target specific metadata members when possible to avoid false replacements.
* **Limit to five** – ARM enforces a max of 5 parameters; combine similar changes into one rule.
* **Test in Sandbox** – run a dry-run deployment to validate your substitutions before Production.
* **Clone, don’t copy-paste** – use the **Clone** icon to reuse rule logic with small tweaks.

With Search & Substitute configured, your deployments self-adjust to each environment—no manual XML edits required.
