# String Replacements During Install

During artifact installation, sfp automatically applies string replacements to convert placeholder values to environment-specific values based on the target org.

### How It Works

When installing artifacts with embedded replacement configurations:

1. **Org Detection**: Identifies the target org alias and whether it's a sandbox or production org
2. **Value Resolution**: Determines the appropriate replacement value based on org alias or defaults
3. **File Modification**: Applies replacements to matching files before deployment
4. **Deployment**: Deploys the modified components to the target org

### Environment Resolution

Replacements are resolved in this order:

1. **Exact alias match**: If the org alias matches a configured environment
2. **Default value**: For sandbox/scratch orgs when no exact match is found
3. **Error**: For production orgs without explicit configuration

### Installation Output

During installation with replacements, you'll see:

```
Text replacements for org alias dev (sandbox)
Total replacement configs 3
Modified APIService.cls with 2 replacements
Modified ConfigService.cls with 1 replacements
Replacements summary: 3 replacements in 2 files using dev environment
```

### Command Line Options

#### Disable Replacements

To skip replacements during installation:

```bash
sfp install --targetorg dev --artifactdir artifacts --no-replacements
```

#### Override Replacements

To use a custom replacement configuration file:

```bash
sfp install --targetorg dev --artifactdir artifacts --replacementsoverride custom-replacements.yml
```

### Production Deployments

Production deployments require explicit configuration for the org alias. If no configuration is found, the installation will fail:

```
ERROR: No replacement value found for production org with alias 'prod'
Production deployment requires explicit configuration for alias 'prod' in replacement 'API Endpoint'
```

### Troubleshooting

#### No Replacements Applied

* Verify the artifact was built with replacements embedded
* Check that glob patterns match your files
* Ensure the org alias has configured values

#### Wrong Values Applied

* Verify org alias with `sf org list`
* Check environment resolution order
* Ensure production orgs have explicit configuration

### Related Documentation

* [String Replacements Overview](/flxbl/sfp/development/string-replacements.md)
* [String Replacements Configuration](/flxbl/sfp/building-artifacts/configuring-installation-behaviour-of-a-package/string-replacements.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.flxbl.io/flxbl/sfp/installing-an-artifact/string-replacements-during-install.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
