---
id: scripting-pre-execution
title: "Pre-execution scripts"
summary: "Change a component's configuration for each record before it runs - a file name from the record, a URL per tenant. Written in C#, Python or JavaScript from the Config scripts row."
audience: user
keywords: "pre-execution, config script, Configure, configuration, dynamic configuration, per message"
---
# Pre-execution scripts

A pre-execution script changes a component's configuration just before the component handles a record. Use it when a
setting depends on the data: a file name built from the record, a URL chosen per customer, a query limit from the
metadata.

For a value built from text, a [binding expression](/documentation/overview/concepts#configuration-values) is shorter. Use a
pre-execution script when you need logic.

## Add one

Select the component. In its properties, the **Config scripts** row has a C#, a Python and a JavaScript icon. Click
one to open its editor. **Clear pre execution scripts** removes them all.

The scripts run for every record, before the component's own work, in the order C#, Python, JavaScript.

## C#

```csharp
public void Configure(IMetaData metaDataInstance, IViaType pluginConfig, IViaType inputData)
{
    var config = pluginConfig.Cast<FileWriterConfig>();
    var metaData = (viauser.FlowMetaData)metaDataInstance;
    var order = inputData.Cast<Order>();
    config.FileName = $"order-{order.Id}.json";
}
```

`config` is the component's configuration with the same field names as in the properties. Whatever you set applies to
this record. The `Services` property gives you the [flow services](./services).

## Python and JavaScript

The template gives you the metadata and the configuration as objects:

```python
def configure(metaDataId: int, configId: int, inputDataId: int):
    metaData = FlowMetaData(metaDataId)
    config = FileWriterConfig(configId)
    config.FileName = "orders.json"
```

```javascript
function configure(metaDataId, configId, inputDataId) {
    var metaData = new FlowMetaData(metaDataId);
    var config = new FileWriterConfig(configId);
    config.FileName = "orders.json";
}
```
