# Replacement scripts

## Introduction

Having [chosen to configure script replacements for a virtual environment](/product-documentation/virtual-environments/implementing-virtual-environments/configuring-a-virtual-environment-version/configuring-virtual-environment-replacements.md#configuring-replacements-for-a-virtual-environment-version), a new replacement rule is displayed, ready for you to configure:

<figure><img src="/files/GrvCJTVioosAqJVVWXzz" alt=""><figcaption></figcaption></figure>

Having defined the first rule, you can add more - you must create one replacement rule for every [script](/product-documentation/developer-hub/custom-scripting.md) that you need to replace in every process flow that will run in this environment.&#x20;

## Defining replacement rules for a script

{% stepper %}
{% step %}
**Select the required ORIGINAL script**

Use the `original` dropdown list to select the first script in a 'master' process flow that must be replaced when this process flow runs in the given virtual environment - for example:

<figure><img src="/files/7hiqzBFwf48Bf6vWYIFL" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
As you work through your replacement configuration, it's helpful to view related ['master' process flows](/product-documentation/virtual-environments/implementing-virtual-environments/creating-a-master-process-flow.md) in another browser tab. You can duplicate a Patchworks browser tab and navigate to a different page whenever needed.
{% endhint %}
{% endstep %}

{% step %}
**Select the required ORIGINAL script version**

Move down to the field below and choose which version of the selected script to apply - for example:

<figure><img src="/files/RFmMAVn94lDpgocCAoWv" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Select the required REPLACEMENT script**

Use the `replacement` dropdown list to select the replacement script that must be used when this process flow runs in the given virtual environment - for example:

<div align="left"><figure><img src="/files/Hj3wJUDmSZG6EgjAepCu" alt=""><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}
**Select the required REPLACEMENT script version**

Move down to the field below and choose which version of the selected script to apply - for example:

<figure><img src="/files/OnlJY55aOCRdZd9yin0g" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Confirm your selections**

Click the `create` button (associated with this replacement rule) to confirm your selections:

<figure><img src="/files/kP22AyH2Pi01ikNEcDzM" alt=""><figcaption></figcaption></figure>

The rule is added:

<figure><img src="/files/QSYT1k0WLfrieOmx4dxH" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Once a rule is confirmed, it can't be edited. If you need to change a replacement rule, use the 'trash' icon to remove it and add a new one.
{% endhint %}
{% endstep %}

{% step %}
**Add more replacement rules for scripts**

To add another replacement rule for a script, click the top-right `create` button:

<figure><img src="/files/euVMvAfoCGyUTNLHyWHX" alt=""><figcaption></figcaption></figure>

Update the new rule as required, then click the associated `create` button to confirm your selections:

<figure><img src="/files/jWx8E4n5QnI7mhhCMF3l" alt=""><figcaption></figcaption></figure>

Repeat as many times as needed to define all required script replacements for all process flows that will be running in this virtual environment.

{% hint style="info" %}
If you don't want to define ALL script lookup replacements now, that's OK. For example, you might choose to add the minimum number of replacements needed for [testing](/product-documentation/virtual-environments/implementing-virtual-environments/testing-a-process-flow-against-a-virtual-environment.md), then define remaining rules (in a [new draft](/product-documentation/virtual-environments/implementing-virtual-environments/configuring-a-virtual-environment-version/understanding-virtual-environment-versions.md)) later, after initial testing is complete.
{% endhint %}
{% endstep %}
{% endstepper %}


---

# 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://doc.wearepatchworks.com/product-documentation/virtual-environments/implementing-virtual-environments/configuring-a-virtual-environment-version/configuring-virtual-environment-replacements/replacement-scripts.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.
