# Installation Control Examples

### Creating Ion Actions for A-Bomb Installations

#### Objective

This outlines the steps to develop ion actions for A-bomb installations, focusing on identifying and utilizing necessary IDs for successful execution of the context query. This aids in developing ION Actions.

#### Key Steps

**Step 1: Understand the Context for Ion Actions** [0:00](https://loom.com/share/d8dd4e1a7eb844d4bf74e3a11f5457b1?t=0)

* Create an abomInstallation Action and start out with this base template for the context query (INITIAL SETUP SHOWN IN IMAGE BELOW):

```
query ($buildRequirementId: ID!, $partInventoryId: ID!) {
  abomInstallation(
    buildRequirementId: $buildRequirementId
    partInventoryId: $partInventoryId
  ) {
    id
    partInventory {
      id
    }
  }
}
```

* The inputs necessary to test the context for this rule will be the following.

```
{
  "buildRequirementId":INSERT ID HERE, 
  "partInventoryId":INSERT ID HERE
}
```

* Recognize that A-bomb installations require two IDs:
  * Build Requirement ID
  * Part Inventory ID
* These IDs are essential for rule context development.
* Once the ION Action is live, these IDs will be passed into the ion action during execution. To help develop these rules we recommend the following steps to know what IDs to test with.

<figure><img src="/files/0nTnARs9xsB1TjcAyzLb" alt=""><figcaption></figcaption></figure>

**Step 2: Install GraphQL Network Inspector** [1:32](https://loom.com/share/d8dd4e1a7eb844d4bf74e3a11f5457b1?t=92)

* Install the [GraphQL Network Inspector tool](https://chromewebstore.google.com/detail/graphql-network-inspector/ndlbedplllcgconngcnfmkadhokfaaln?pli=1) to monitor the execution of your ion actions.
* This tool helps you see the IDs and data being processed so you can effectively develop the ION Action.

**Step 3: Execute a Mutation to Install Part Inventory** [2:15](https://loom.com/share/d8dd4e1a7eb844d4bf74e3a11f5457b1?t=135)

<figure><img src="/files/6WstQd2LFFdBefLCsBZs" alt=""><figcaption></figcaption></figure>

* Right click and open the inspect tool, toggle to the GraphQL tab so you can see what mutations are called.
* Replicate the action you are trying to control, in this case installing something onto an aBOM.
* Focus on the mutation called `install part inventory`.
* See that the request includes both a Build Requirement ID and Part Inventory ID.

**Step 4: Analyze the Response for IDs** [3:14](https://loom.com/share/d8dd4e1a7eb844d4bf74e3a11f5457b1?t=194)

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

* Check the response tab for the InstallPartInventory query which will contain a `partInventoryId`, which may differ from the one passed in during the request (in the case were splitting happened from a partial install).
* Note the `buildRequirementId` and the new `partInventoryId` for your records, you can pass these into the inputs within the ION Actions context interface to see what the context will return.

**Step 5: Save the Context of the Rule Query** [5:26](https://loom.com/share/d8dd4e1a7eb844d4bf74e3a11f5457b1?t=326)

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

* Pass in the input variables based on the query response to understand what this specific context returned. This will help you define the logic to use within the code portion of the ION Action. ***In the example image above the id's happened to be:***

```
{
  "buildRequirementId":2622, 
  "partInventoryId":2079
}
```

* Save the context query of your ION action with the explicit save icon below the play button to avoid re-entering the query formatting in future sessions. (You will need to specify the query inputs each time.)

**Step 6: Access Origin Part Inventory Attributes** [6:28](https://loom.com/share/d8dd4e1a7eb844d4bf74e3a11f5457b1?t=388)

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

* If you split an inventory, you can use the originPartInventory field to access information related to the original inventory item "pre" the split.
* Now that you know what the context will return, write code within the code tab to determine installation eligibility!
  * ION Actions code can now access the context in the following manor: `context.get("abomInstallation", {}).get("partInventory", {}).get(.......`

#### Cautionary Notes

* Ensure that you are using the correct IDs to avoid errors in your ion actions.

#### Tips for Efficiency

* Regularly use the GraphQL Network Inspector to familiarize yourself with the IDs and data flow.

#### Link to Loom

<https://loom.com/share/d8dd4e1a7eb844d4bf74e3a11f5457b1>


---

# 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-v2.firstresonance.io/os/ion-actions/installation-control-examples.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.
