# Configuring virtual environment replacements

## Introduction

Having created a virtual environment [draft version](https://doc.wearepatchworks.com/product-documentation/virtual-environments/implementing-virtual-environments/configuring-a-virtual-environment-version), you can configure a set of replacement rules for components used in any process flows that run in the associated environment. For example:

* *If a process flow running in this environment includes NetSuite Instance - MASTER, then replace it with NetSuite Instance - LIVE.*
* *If a script running in this environment includes a script named Script for Currency Conversion - MASTER, then replace it with Script for Currency Conversion - LIVE.*

## What replacements can I configure for a virtual environment?

You can define overrides/replacements for the following process flow components for any virtual environment:

| Item                                                                                                                                                                                                  | Related shape/area                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [Connector instances](https://doc.wearepatchworks.com/product-documentation/connectors-and-instances/working-with-instances/adding-an-instance)                                                       | [Connector](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/connector-shape)                                                                                                                                                                                                                                                                                                                                                                                                                    |
| [Data pools](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/advanced-shapes/de-dupe-shape/working-with-data-pools#adding-a-data-pool) | [De-dupe](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/advanced-shapes/de-dupe-shape)                                                                                                                                                                                                                                                                                                                                                                                                                        |
| [Cross-reference lookups](https://doc.wearepatchworks.com/product-documentation/process-flows/cross-reference-lookups/adding-a-cross-reference-lookup)                                                | [Map shape (transform function](https://doc.wearepatchworks.com/product-documentation/process-flows/cross-reference-lookups/using-a-cross-reference-lookup-in-field-transformations))                                                                                                                                                                                                                                                                                                                                                                                          |
| [Scripts](https://doc.wearepatchworks.com/product-documentation/developer-hub/custom-scripting/creating-and-testing-custom-scripts)                                                                   | <p><a href="../../../process-flows/building-process-flows/process-flow-shapes/advanced-shapes/script-shape">Script shape</a></p><p><a href="../../../process-flows/building-process-flows/process-flow-shapes/standard-shapes/map-shape/working-with-field-transformations/available-transform-functions/other-transform-functions/script-transform-function">Map shape (transform function)</a></p>                                                                                                                                                                           |
| [Company caches](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/advanced-shapes/cache/add-to-cache-shape)                             | <p><a href="../../../process-flows/building-process-flows/process-flow-shapes/advanced-shapes/cache/add-to-cache-shape">Add to cache shape</a><br><a href="../../../process-flows/building-process-flows/process-flow-shapes/advanced-shapes/cache/load-from-cache-shape">Load from cache shape</a><br><a href="../../../process-flows/building-process-flows/process-flow-shapes/standard-shapes/map-shape/working-with-field-transformations/available-transform-functions/other-transform-functions/cache-lookup-transform-function">Map shape (transform function)</a></p> |
| [Flow variables](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/dynamic-variables/flow-variables)                                                         | [Process flow settings](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-settings)                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| [Flow queue priority](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-settings#understanding-process-flow-settings)                           | [Process flow settings](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-settings)                                                                                                                                                                                                                                                                                                                                                                                                                                      |

## Creating replacement rules

To configure replacements that must be made when process flows are running in a virtual environment, you define *replacement rules*. Typically, a rule requires you to select an existing component in a master process flow, followed by a replacement component. These steps are summarised below.

{% hint style="info" %}
Before starting, ensure that [all required replacement components have been created](https://doc.wearepatchworks.com/product-documentation/virtual-environments/implementing-virtual-environments/creating-replacement-components-for-a-virtual-environment).
{% endhint %}

{% stepper %}
{% step %}
**Access the draft version for your virtual environment**

If you're not there already, [access the draft version](https://doc.wearepatchworks.com/product-documentation/virtual-environments/implementing-virtual-environments/configuring-a-virtual-environment-version) in the relevant virtual environment.

{% hint style="info" %}
A virtual environment will only ever have one `draft` version. If you've just [created a virtual environment](https://doc.wearepatchworks.com/product-documentation/virtual-environments/implementing-virtual-environments/creating-a-virtual-environment), you'll see that a `draft` version has been generated automatically.&#x20;
{% endhint %}
{% endstep %}

{% step %}
**Choose the first component to configure**

All [process flow components that can be replaced](#what-replacements-can-i-configure-for-a-virtual-environment) are listed - click the first one that you want to update, for example:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FIr0OnHNOLGEKTttHXs82%2Freplacement%20selector%20-%20instances.png?alt=media&#x26;token=6f6eac0a-2264-4dc5-bd67-d7daed7c5f72" alt=""><figcaption></figcaption></figure></div>

{% hint style="info" %}
Did you see the `notes` option at the top of this page, beneath the title? You can use this to add internal notes about this version - for example:

![](https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2Fvpr1jloa3cUr1iwLOfcS%2Freplace%20instance%20notes.png?alt=media\&token=0f3d3c38-e02e-4439-b23a-f00a7311aa55)

Any notes added here are displayed above the notes option, and stay with this version throughout its [lifecycle](https://doc.wearepatchworks.com/product-documentation/virtual-environments/implementing-virtual-environments/understanding-virtual-environment-versions#the-lifecycle-of-a-virtual-environment-version))

<img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2Fc1sZJ70oWs7TOI9NGXR9%2Freplace%20instance%20notes%20b.png?alt=media&#x26;token=c920e599-5614-4fc2-9b5e-149b5332f5a6" alt="" data-size="original">
{% endhint %}
{% endstep %}

{% step %}
**Create a new replacement rule**

Click the `create` button to add a new replacement rule:

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FvTjh7f3rThpN4ZdtJkDq%2Fcreate%20item.png?alt=media&#x26;token=1bed121e-fdfa-4711-93f1-b6b521d98f28" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
If you don't see a `create` button, it's likely that you didn't access a `draft` version at the start (replacements must be configured in a `draft` version and then deployed).
{% endhint %}
{% endstep %}

{% step %}
**Configure the replacement rule**

Except for [variables](https://doc.wearepatchworks.com/product-documentation/virtual-environments/implementing-virtual-environments/configuring-a-virtual-environment-version/configuring-virtual-environment-replacements/replacement-variables) and [flow priorities](https://doc.wearepatchworks.com/product-documentation/virtual-environments/implementing-virtual-environments/configuring-a-virtual-environment-version/configuring-virtual-environment-replacements/replacement-flow-queue-priorities), replacement details are defined by selecting an existing component in your master process flow (on the left) and the item to be used instead (on the right). Click the `create` button to confirm.

{% hint style="info" %}
For specific guidance on configuring different components, please see: [Replacement instances](https://doc.wearepatchworks.com/product-documentation/virtual-environments/implementing-virtual-environments/configuring-a-virtual-environment-version/configuring-virtual-environment-replacements/replacement-instances) | [Replacement caches](https://doc.wearepatchworks.com/product-documentation/virtual-environments/implementing-virtual-environments/configuring-a-virtual-environment-version/configuring-virtual-environment-replacements/replacement-caches) | [Replacement cross-reference lookups](https://doc.wearepatchworks.com/product-documentation/virtual-environments/implementing-virtual-environments/configuring-a-virtual-environment-version/configuring-virtual-environment-replacements/replacement-cross-reference-lookups) | [Replacement scripts](https://doc.wearepatchworks.com/product-documentation/virtual-environments/implementing-virtual-environments/configuring-a-virtual-environment-version/configuring-virtual-environment-replacements/replacement-scripts) | [Replacement data pools](https://doc.wearepatchworks.com/product-documentation/virtual-environments/implementing-virtual-environments/configuring-a-virtual-environment-version/configuring-virtual-environment-replacements/replacement-data-pools) | [Replacement variables](https://doc.wearepatchworks.com/product-documentation/virtual-environments/implementing-virtual-environments/configuring-a-virtual-environment-version/configuring-virtual-environment-replacements/replacement-variables) | [Replacement flow priorities](https://doc.wearepatchworks.com/product-documentation/virtual-environments/implementing-virtual-environments/configuring-a-virtual-environment-version/configuring-virtual-environment-replacements/replacement-flow-queue-priorities).
{% endhint %}
{% endstep %}

{% step %}
**Add more replacement rules for this component**

Repeat steps 3 and 4 if you need additional replacement rules for the selected component.

{% hint style="info" %}
Keep in mind that you might deploy a single process flow to a given virtual environment or multiple process flows. Any replacements that you define here should cover ALL process flows that are deployed to this virtual environment. Don't worry if you're unsure which flows will be deployed - start with whatever you do know and come back to [update the configuration later](https://doc.wearepatchworks.com/product-documentation/virtual-environments/managing-virtual-environments-versions-and-flows/managing-virtual-environment-configuration-versions/updating-a-virtual-environment-version), if necessary.
{% endhint %}
{% endstep %}

{% step %}
**Add replacement rules for other components**

Repeat steps 3, 4, and 5 to add replacement rules for all required components.
{% endstep %}

{% step %}
**Deploy the draft version**

When you're satisfied that all required replacements are configured, you can go on to [deploy the draft version](https://doc.wearepatchworks.com/product-documentation/virtual-environments/implementing-virtual-environments/deploying-the-configuration-for-a-virtual-environment).
{% endstep %}
{% endstepper %}
