# Auto Set Custom Attribute

## 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](/workflow-builder/ion-webhooks-component.md) 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`&#x20;

<figure><img src="/files/bBQ7BrZ76A6g5tlVZlSs" alt=""><figcaption></figcaption></figure>

* 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`.

<figure><img src="/files/K4Bpq9F12UqJjh5gsn0P" alt=""><figcaption></figcaption></figure>

&#x20;      Configure the Connection, GraphQL Query, and GraphQL Variables

<figure><img src="/files/QUoYMzNWlecHnJJXXrha" alt=""><figcaption></figcaption></figure>

&#x20;      Use the following query:&#x20;

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

&#x20;     Use the following query variables:

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

&#x20;      Add a reference in the query variable to the incoming id from the webhook trigger

<figure><img src="/files/Q1ciApqvFd9Gp3YairOl" alt=""><figcaption></figcaption></figure>

&#x20;      Refer to [this](/workflow-builder/first-resonance-ion-component/using-the-first-resonance-ion-component.md) 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` &#x20;

<figure><img src="/files/dt0h2qMac7dWq4UCJ08V" alt=""><figcaption></figcaption></figure>

&#x20;      Configure the branch step to check the Tracking Level:

<figure><img src="/files/B6MHBqq8AcwLjXz71JMO" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/Be59pDZKdPIqLaAztIOn" alt=""><figcaption></figcaption></figure>

&#x20;      Select `does not exist` for the Operator

<figure><img src="/files/lBJNe2RPJSI9lDgXbRyq" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/VDoEyppCkaNuT9R9JdAZ" alt=""><figcaption></figcaption></figure>

&#x20;      Enter `trackingStrategy` for the Key and `N/A` for the Value

<figure><img src="/files/GCeSLRlLQXsiyIgXbs4C" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/ZfLYn9y19u9XhP2Gcxu4" alt=""><figcaption></figcaption></figure>

&#x20;     Enter `trackingStrategy` for the Key

&#x20;     Enter references to the `trackingType` and `sourcingStrategy` for the Value separated by a -

<figure><img src="/files/4bHWiaRYlybR5X4Zc8E2" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/uPTaMsfpVF1N99jpOSqO" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/x3tjZk5n5PvWaj1iLpkn" alt=""><figcaption></figcaption></figure>

* 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`

<figure><img src="/files/fdvd1ZRPVDTuGVNl5G6o" alt=""><figcaption></figcaption></figure>

&#x20;      Enter in `trackingStrategy` for the Key&#x20;

<figure><img src="/files/COvDzdRyls2DVTgTEDHo" alt=""><figcaption></figcaption></figure>

* 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`.

<figure><img src="/files/l4u3IY1U38Jr01bl07Qi" alt=""><figcaption></figcaption></figure>

&#x20;      Configure the Connection, GraphQL Query, and GraphQL Variables

<figure><img src="/files/QUoYMzNWlecHnJJXXrha" alt=""><figcaption></figcaption></figure>

&#x20;      Use the following query:&#x20;

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

&#x20;     Use the following query variables:

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

&#x20;      Add a references in the query variable to the partId, etag, and value.

&#x20;      Reference to the partId:&#x20;

<figure><img src="/files/dimee8xLzNQz5SrZEjhu" alt=""><figcaption></figcaption></figure>

&#x20;      Reference to the etag:&#x20;

<figure><img src="/files/remjwSS3m50re91Slcyx" alt=""><figcaption></figcaption></figure>

&#x20;      Reference to the value:&#x20;

<figure><img src="/files/caeMBWFrEtvz6VhaXyQr" alt=""><figcaption></figcaption></figure>

&#x20;      The query variables should look like this:&#x20;

<figure><img src="/files/S9PCZXIgOVIrPeqQ9ljf" alt=""><figcaption></figcaption></figure>

&#x20;      Refer to [this](/workflow-builder/first-resonance-ion-component/using-the-first-resonance-ion-component.md) for detailed documentation on using the First Resonance ION component.

The final flow should resemble this:&#x20;

<figure><img src="/files/Z0NQ5sQMAsNebrQqpyJs" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://manual.firstresonance.io/workflow-builder/example-flows/auto-set-custom-attribute.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
