[The manual for the New ION Experience has been released.](https://docs.firstresonance.io/)

For the complete documentation index, see [llms.txt](https://manual.firstresonance.io/llms.txt). This page is also available as [Markdown](https://manual.firstresonance.io/workflow-builder/example-flows/auto-set-custom-attribute.md).

## Scenario

Every time a part is created, set the custom attribute `Tracking Strategy` based on the following table:

| Tracking Level | Sourcing Strategy | Tracking Strategy |
|----------------|-------------------|-------------------|
| None           | Make              | N/A               |
| None           | Buy               | N/A               |
| Lot            | Make              | Lot - Make        |
| Lot            | Buy               | Lot - Buy         |
| Serial         | Make              | Serial - Make     |
| Serial         | Buy               | Serial - Buy      |

### Trigger

The flow should be triggered when a part is created.

### Steps

- Create a new flow using the [ion-webhooks](https://manual.firstresonance.io/workflow-builder/ion-webhooks-component) component. Configure the ion-webhooks step by setting the Connection, providing a name for the webhook receiver, and adding an action. In this example we want the flow to be triggered when a part is created so the action will be `Parts - Create`

- Add a step that uses the `First Resonance ION` component. Click on the `+` icon at the bottom of the flow then search for `First Resonance ION`. Click on `Run GraphQL Query`.

Configure the Connection, GraphQL Query, and GraphQL Variables

Use the following query:

```graphql
query getParts($filters: PartsInputFilters!) {
  parts(filters: $filters) {
    edges {
      node {
        id
        _etag
        partNumber
        sourcingStrategy
        trackingType
      }
    }
  }
}
```

Use the following query variables:

```json
{
  "filters": {
    "id": {
      "eq":
    }
  }
}
```

Add a reference in the query variable to the incoming id from the webhook trigger

Refer to [this](https://manual.firstresonance.io/workflow-builder/first-resonance-ion-component/using-the-first-resonance-ion-component) for detailed documentation on using the First Resonance ION component.

- Add a step that branches based on the value of the Tracking Level. Search for "branch" and select `If Condition is Met`

Configure the branch step to check the Tracking Level:

Click the icon in the first `Field` and configure the input to the output of the previous step.

Select `does not exist` for the Operator

- Click on the `+` icon in the "Tracking is None" side of the branch. Search for "Execution save value". Select `Execution - Save Value`

Enter `trackingStrategy` for the Key and `N/A` for the Value

- Click on the `+` icon in the "Else" side of the branch. Search for "Execution save value". Select `Execution - Save Value`

Enter `trackingStrategy` for the Key

Enter references to the `trackingType` and `sourcingStrategy` for the Value separated by a -

- Add a step at the end of the flow that will return the value of `trackingStrategy`. Click on the `+` icon at the bottom of the flow then search for "Execution get value". Click on `Execution - Get Value`

Enter in `trackingStrategy` for the Key

- Add a step to set a custom attribute to the value of `trackingStrategy`. Click on the `+` icon at the bottom of the flow then search for "First Resonance ION". Click on `Run GraphQL Query`.

Configure the Connection, GraphQL Query, and GraphQL Variables

Use the following query:

```graphql
mutation UpdatePartAttributes($input: UpdatePartAttributeInput!) {
  updatePartAttribute(input: $input) {
    partAttribute {
      partId
      Etag
      key
      value
    }
  }
}
```

Use the following query variables:

```json
{
  "input": {
    "partId": ,
    "key": "",
    "value": "",
    "etag": ""
  }
}
```

Add a references in the query variable to the partId, etag, and value.

Reference to the partId:

Reference to the etag:

Reference to the value:

The query variables should look like this:

The final flow should resemble this:
