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

# Storage rules

> Predicate guards that validate inventory transactions: block with an error, or warn and let the user continue.

A **storage rule** validates an inventory transaction during posting. If its condition fails, the rule either **blocks** the transaction or **warns** and allows the user to acknowledge the warning. Rules apply to **items** or **work centers**.

For example, to prevent batch chemicals from entering ambient bins, target **items** in the chemicals group, enable **receipt** and **place** operations, and require `storageUnit.storageTypeId` `eq` the cold-storage type. Set severity to **error** and the message to `{item.id} must be stored in cold storage`. A receipt into any other storage type is rejected with that message.

NOTE

Storage rules only validate data. They do not transform values, set defaults, or compute prices. A rule returns a message and severity.

## What a rule checks

Each rule holds a small **condition tree**, a match kind over one or more field/operator/value rows:

* **Match kind**: `all` (every condition must hold), `any` (at least one), or `none` (none may hold).
* **Field**: chosen from a fixed registry: item facts (`item.type`, `item.replenishmentSystem`,
  `item.itemTrackingType`, custom fields), storage location (`storageUnit.storageTypeId`,
  `storageUnit.locationId`), work-center facts, and the line's `transaction.quantity`.
* **Operator**: `eq`, `neq`, `in`, `notIn`, `isSet`, `isNotSet`, `gt`, `lt`.

The **message** shown on a violation supports tokens like `{item.id}` and `{transaction.quantity}`, so the
text can name the offending line. The rule "passes" when its conditions hold; a violation fires when they
don't.

NOTE

Aside from the `isSet` / `isNotSet` checks, a condition pointing at a field that has **no value** fails as a
*"…is required"* violation. So the same rules double as presence checks (for instance, require a lot number
before a shipment can post).

## Operators

| Operator | Meaning |
| - | - |
| `eq` · `neq` | equals · does not equal |
| `in` · `notIn` | value is · is not in a list |
| `gt` · `lt` | greater than · less than |
| `isSet` · `isNotSet` | field has · does not have a value |

## Where rules fire

A rule lists the **surfaces** (transaction types) it applies to. The available surfaces depend on the
target:

| Target | Surfaces |
| - | - |
| Item | receipt, shipment, stockTransfer, warehouseTransfer, inventoryAdjustment, place, pick |
| Work center | operationStart, operationFinish, materialIssue, materialReceive |

Rules are evaluated server-side as the transaction posts, before any accounting or stock movement is
written. A blocked transaction writes nothing.

## Block or warn

| Severity | Behavior |
| - | - |
| `error` | Blocks the transaction until the condition is satisfied. |
| `warn` | Surfaces the message but lets the user **acknowledge and continue**. |

NOTE

An `error` always blocks. A `warn` blocks only until the user acknowledges it, then the same submit goes
through — useful for "are you sure?" guardrails that shouldn't hard-stop the floor.

For instance, a `warn` rule on **inventory adjustments** where `transaction.quantity` `gt` `750`, with the
message `Large adjustment — confirm the count`, lets the count post once the user acknowledges it while still
flagging the outlier.

## Scope and assignment

A rule reaches the lines it applies to in one of two ways:

* **By filter**: item-target rules can scope to **item types** and/or **item groups**, combined with OR or
  AND. An empty filter matches **every** item.
* **By assignment**: pin a rule to a specific item from the item's **Rules** tab, or to a specific work
  center. Work-center rules can also be set to apply to all work centers.

## Rule fields

FieldType

<details>
  <summary>**Name**</summary>

  The rule's name (required, up to 120 characters).
</details>

<details>
  <summary>**Description**</summary>

  Optional notes for your team.
</details>

<details>
  <summary>**Severity**</summary>

  `error` (block) or `warn` (acknowledge and continue).
</details>

<details>
  <summary>**Conditions**</summary>

  The match kind plus the field / operator / value rows.
</details>

<details>
  <summary>**Message**</summary>

  Required, up to 500 characters. Shown on a violation; supports `{token}` interpolation.
</details>

<details>
  <summary>**Surfaces**</summary>

  Which transactions the rule fires on. At least one is required, and a condition's field must be available on every surface you pick.
</details>

<details>
  <summary>**Target**</summary>

  `item` or `workCenter`.
</details>

<details>
  <summary>**Item filters**</summary>

  Item types and/or groups to scope a rule (empty = all items).
</details>

<details>
  <summary>**Active**</summary>

  Whether the rule is currently evaluated.
</details>

## Where to manage them

Storage rules live in the **Inventory** area, under **Storage Rules**. Create, edit, and toggle them there.
To attach an existing rule to a single item, use the **Rules** tab on that item.

HEADS UP

Storage rules are available on the **Business** plan. On other
plans the screen shows an upgrade prompt and no rules are evaluated.

## Related

**Sales rules**

The sibling rule family: the same condition builder, applied to quote, sales order, and sales invoice
lines.

[Open](/docs/reference/sales-rules.md)

**Items**

The most common rule target: scope by item type or group, or assign per item.

[Open](/docs/reference/items.md)

**Inventory**

Storage rules run on inventory transactions: receipts, shipments, transfers, picks.

[Open](/docs/reference/inventory.md)

**Work centers**

The other target: guards on operation start/finish and material issue/receive.

[Open](/docs/reference/work-centers.md)

**Shelf life**

The other inventory guard: date tracked stock and block it once expired.

[Open](/docs/reference/shelf-life.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.