# Defining a mediation contract using the Data Shaper workflow template

To properly configure Data Shaper and set transformation events, you need to define a **mediation contract** in Data Mover.&#x20;

1. Go to **Design** → **Contracts**.
2. Click the **New** button.
3. In the **INFO** section:
   * Assign a unique **Name** to the contract.
   * Select **MEDIATION** from the Contract type drop-down list.
4. Click **CONTINUE** to proceed to the **ACTION** section.

<figure><img src="https://4045370068-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyxV8XEI7kgTw22LXcPL6%2Fuploads%2FmHNOTS9oi51KeHnKc9zn%2Fimage.png?alt=media&#x26;token=a8f1d5d1-5a35-44d1-b7cd-4355fbc47667" alt="" width="375"><figcaption></figcaption></figure>

5. In the **ACTION** section, choose the trigger that will initiate the workflow instance.\
   For example, to start the action when a file is written to a specific VFS, select the **New File** trigger.
6. In the **Workflows** list, select the [Data Shaper workflow](https://docs.primeur.com/data-shaper-1.20/using-data-shaper-in-data-mover/defining-a-data-shaper-workflow-template) to be used in the contract.
7. Click **SAVE** to continue.

Here, select the trigger that will initiate the workflow instance. For example, if you want the action to start when the file is written on a specific VFS, select the **New File** trigger.&#x20;

<figure><img src="https://4045370068-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyxV8XEI7kgTw22LXcPL6%2Fuploads%2FoMrvhZwA3MVQMrmUunxn%2Fimage.png?alt=media&#x26;token=10000f5d-35da-4f9e-9ae1-69124ce55fb3" alt="" width="375"><figcaption></figcaption></figure>

After saving, you will be prompted to configure the actions for your contract.

The <img src="https://files.readme.io/3f1fcd5-attention_icon.png" alt="" data-size="line"> icon next to the Action Name indicates that the action variables have not yet been configured.

In the Source Virtual Path section, select the **Actor**, **VFS**, and **virtual path** where the source files are stored. Data Mover will retrieve the file from this path and apply the transformation defined in the workflow.

Select the **Cluster**.

Choose the **Actor**, **VFS**, and **virtual path** where the transformed file will be stored.

In the **Datashaper Payload** section, select the **Data Shaper workflow** to be used. This list displays workflows from the Asynchronous Web Service folder. For details on creating these workflows, refer to the [Publish the Workflow to Data Mover](https://docs.primeur.com/data-shaper-1.20/using-data-shaper-in-data-mover/using-the-data-shaper-designer/publish-the-workflow-to-data-mover) page.

In the figure below, you can see the workflows available in the **Data Shaper Asynchronous Web Service folder** (left) and the corresponding entries in the **Datashaper Payload list of the mediation contract** (right).

<figure><img src="https://4045370068-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyxV8XEI7kgTw22LXcPL6%2Fuploads%2FbqnT8Ijeq2GtzRksVMMA%2Fimage.png?alt=media&#x26;token=f2e5133f-91dd-4fdd-b497-77744a2f185d" alt=""><figcaption></figcaption></figure>

When the workflow is selected in the **Datashaper Payload** field, the associated variables will appear in the contract. Within these variables, you need to input the new value you want to assign to the variable's field. Once the contract is executed, the file will be updated with the new required values.

Read the **Example Use Case** below with a detailed scenario.

Once all variables are set, the <img src="https://files.readme.io/682340e-check_icon.png" alt="" data-size="line">  icon will appear next to the Action Name, indicating that configuration is complete.

Click **SAVE** and your contract will now appear in the result list.

#### Example Use Case

Imagine a file containing a list of new hires, where:

* The field `company` must be updated to `Primeur`.
* A new field `dep` must be added with the value `Delivery`.

To achieve this:

1. In **Design** → **Data Shaper**, define a workflow that performs these operations and define the two variables (company, dep) to be modified.
2. In **Design** → **Contracts**, create a mediation contract that uses the workflow and specifies the values for the variables.

For example, given these variables in Data Shaper:

<figure><img src="https://4045370068-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyxV8XEI7kgTw22LXcPL6%2Fuploads%2FDev3XpYkPVXKeUI0aUXp%2Fimage.png?alt=media&#x26;token=91e3f752-7c71-46d6-bf2b-9a229f251219" alt="" width="370"><figcaption></figcaption></figure>

once the workflow is selected in the **Datashaper Payload** field, the associated variables will appear in the contract and you can assign the new values:&#x20;

<figure><img src="https://4045370068-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyxV8XEI7kgTw22LXcPL6%2Fuploads%2Fen1SZf7EqRnOLfNQdvA4%2Fimage.png?alt=media&#x26;token=26ef830e-6ad2-4d96-b3d7-d9917e609094" alt="" width="366"><figcaption></figcaption></figure>

{% hint style="info" %}
Tip: If the variables do not appear automatically, you can manually enter field-value pairs in the **Workflow parameters** edit box, separated by semicolons. For example:\
![](https://4045370068-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyxV8XEI7kgTw22LXcPL6%2Fuploads%2FKqfVgJf4JcM4Mj0FZVwo%2Fimage.png?alt=media\&token=545212bc-594d-4368-b6d3-69ea15e68c68)
{% endhint %}

Data Shaper workflows can be monitored and logs can be checked in Data Mover. For details, see the next page.&#x20;
