---
title: "Item Barcode Rules"
app: "Warehouse Insight"
section: "Set up"
last_updated: "2024-09-17"
url: "https://insight-works.com/kb/warehouse-insight/barcode-rules/"
---

# Item Barcode Rules

### Item Barcode Rules

Depending on your environment, you may have a mix of barcodes and data formats. To handle this requirement, the application uses the _Barcode Rules_ page. Barcode Rules allow you to configure the logic used to decode each barcode data to correctly return the various pieces of information.

By default, the installation process preloads common rules. Review the rules provided and disable any that do not pertain to your organizational needs.

Configuring the Item Barcode Rules to correctly interpret/parse a barcode requires a knowledge of Regular Expression syntax. For more information on Regular Expression syntax, see Microsoft's _[Regular Expression Language – Quick Reference](https://docs.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-language-quick-reference)_page or find an online Regular Expression tutorial for additional help.

Barcode Rules break out into the following pieces:

- Run Order: Use this to indicate the order rules are processed in. If a successful match is made, no further rules are processed. Your common rules should come first to avoid unnecessary processing.
- Find Text: This is the regular expression string used to parse the barcode data (e.g., _01(.\*)17([0-9])10(.\*)_ ).
- Expression Groups: For each group matched by the regular expression, use $1, $2, and $3 in the Expressions to set the appropriate value.

Barcode rules can be used to capture/interpret the following information:

- Item No.
- Item No. 2: Used to find the Item No. if not already part of the barcode.
- Variant Code
- Serial No.: Used to find the Item No. if not already part of the barcode.
- Lot No.: Used to find the Item No. if not already part of the barcode.
- Expiry Date
- Cross Reference No.: Used to find the Item No. if not already part of the barcode.
- Item Identifier: Used to find the Item No. if not already part of the barcode.
- Item Reference No.: Used to find the Item No. if not already part of the barcode.
- Unit of Measure
- Quantity

If the regular expressions are not sufficient (e.g., referencing additional tables), AL code can be written by subscribing to the appropriate events.

The data parsed by the rule is sent back to the devices and is used (if possible) to help minimize data entry or to take additional action.

For example, a barcode in the format [Item Number] [LotNumber] with a physical scan of 80216-T LOT123. Scanning the item during shipping selects the correct line and causes the quantity dialog to appear with the lot number entry prefilled with LOT123.

The same scenario with a barcode format of [Item Number] with a physical scan of 80216-T selects the correct line, but when the quantity dialog is displayed, has the lot number entry blank requiring the user to type in the correct value manually.

Note: If the Item barcode contains a serial or lot number, the barcode rules can be used to retrieve the item number, expiration, variant, and quantity which can improve performance, reduce errors, and reduce barcode/label sizes.

For assistance interpreting or creating Item Barcode Rules, contact Support.

#### Example: Creating a Barcode Rule

Creating a Barcode Rule shows you how to define and configure a sample barcode rule. The goal is to create a rule that can parse a barcode that has Item, Variant Code, and Quantity in the barcode data.

1. Open the _Barcode Rules_ page in Business Central.
2. Create a new line.
3. Set the following fields:

   1. **Run** **Order**: “70” (The order the rule is processed with lower numbers first, and if a match is found, no other rules are looked at.)
   2. **Find** **Text**: “(.\*)/(.\*)/(.\*)” (The regular expression we use to parse our barcode data with. In this example, we have three groups separated by a “/”.)
   3. **Description**: “Item + Variant + Quantity” (Can be anything and is used to quickly inform others what the rule is looking for.)
   4. **Enabled**: “Checked” (If the rule is disabled, it is not processed by the system.)
   5. **Item No. Expression**: “$1” (The first group result is put into the “Item No. Result” when the barcode is processed.)
   6. **Variant** **Expression**: “$2” (The second group result is put into the “Variant Result” when the barcode is processed.)
   7. **Quantity** **Expression**: “$3” (The third group result is put into the “Quantity Result”.)
4. Type “1896-S/blue/10” and press **Test All Rules**.

![](/wp-content/uploads/kb-legacy/2.2.3-Example-–-Creating-a-Barcode-Rule-300x194.png)

 Note: For more information on barcodes, see the [_Barcode Symbology and Encoding_](/kb/warehouse-insight/barcode-symbology-and-encoding/) page.
