> ## Documentation Index
> Fetch the complete documentation index at: https://docs.alumio.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Copy using a path

> Takes a part of the entity data and copies it.

export const FormField = ({property, label, required = false, diType, uiPatterns, children}) => {
  const patterns = Array.isArray(uiPatterns) ? uiPatterns : uiPatterns ? [uiPatterns] : [];
  return <div style={{
    margin: '1.5rem 0'
  }}>
      <div style={{
    display: 'flex',
    alignItems: 'baseline',
    flexWrap: 'wrap',
    gap: '0.5rem',
    marginBottom: '0.25rem'
  }}>
        <strong>{label}</strong>
        <span style={{
    fontSize: '0.7rem',
    fontWeight: 600,
    textTransform: 'uppercase',
    letterSpacing: '0.04em',
    color: required ? '#6241f5' : '#6b7280'
  }}>
          {required ? 'Required' : 'Optional'}
        </span>
      </div>

      <div>{children}</div>

      {diType || patterns.length > 0 ? <p style={{
    fontSize: '0.85rem',
    color: '#6b7280',
    marginBottom: 0
  }}>
          {diType ? <>
              See the <a href={`/references/${diType}`}>{diType}</a> reference.{' '}
            </> : null}
          {patterns.length > 0 ? <>
              Accepts a <a href={`/documentation/placeholders-and-patterns/patterns#${patterns[0]}`}>pattern</a>.
            </> : null}
        </p> : null}
    </div>;
};

Copies a value from one place in your data to another, leaving the original in place. You point at the data you want with a source pattern and say where the copy should land with a destination pattern. It is handy when a downstream system expects the same value under a different name, or when you want to duplicate a value, for example reusing a shipping address as a billing address. If you do not need to keep the original, use [Move using a path](/references/transformer/pattern-move) instead.

This documentation describes: [Schema](/schemas/transformer/pattern-copy)

## Fields

<FormField property="pattern" label="Source pattern" required uiPatterns="select-source">
  The path to the data you want to copy. Use dot notation to reach into nested data, such as `customer.email`. Use `*` to match every item in a list, such as `products.*.name` to reach the name of every product. Each `*` becomes a numbered group you can reuse in the destination: the first `*` is `$1`, the second is `$2`, and so on.
</FormField>

<FormField property="replacement" label="Destination pattern" required uiPatterns="select-destination">
  The path where the copied value should be placed. Refer back to the groups from the source with `$1`, `$2`, and so on. For a source of `products.*.name`, a destination of `product_names.$1` writes each product name into a `product_names` list, keeping its original position.
</FormField>

<FormField property="conditions[]" label="Conditions" diType="condition">
  One or more checks that decide whether a matched value is actually copied. A value is only copied when every condition you add is met, so you can copy selectively instead of across the board. Leave this empty to always copy.
</FormField>

## Sample data

| Field               | Value              |
| ------------------- | ------------------ |
| Source pattern      | `products.*.name`  |
| Destination pattern | `product_names.$1` |

Input:

```json theme={null}
{
    "products": [
        { "name": "Coffee mug", "sku": "MUG-01" },
        { "name": "Tea pot", "sku": "POT-02" }
    ]
}
```

Output:

```json theme={null}
{
    "products": [
        { "name": "Coffee mug", "sku": "MUG-01" },
        { "name": "Tea pot", "sku": "POT-02" }
    ],
    "product_names": [
        "Coffee mug",
        "Tea pot"
    ]
}
```

The original `products` list is untouched, and a copy of each name now also lives under `product_names` in the same order as the products.

```json Configuration theme={null}
{
  "prototype": "pattern-copy",
  "parameters": {
    "pattern": "products.*.name",
    "replacement": "product_names.$1"
  }
}
```
