# Business Central Item Table (27), Table 6507 and Temporary Tables in AL

> Source: https://netray.co/erp-help/business-central-item-table-27-table-6507-temporary-table-al
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: ERP Help

## Short answer

The Business Central Item table is table 27. Table 6507 is Item Entry Relation, a link table used with item tracking, not the Tracking Specification, which is table 336 and is normally used as a temporary table. A temporary table in AL is an in-memory copy of a table structure that never writes to the database, declared with the temporary keyword or the TableType property.

## Kind

advanced

## System

dynamics

## Erp

Microsoft Dynamics 365 Business Central

## Module

AL Development / Tables

## Query

business central item table

## Alternate Queries

- business central table 6507
- business central temporary table
- business central item table number 27
- al temporary record variable business central

## Applies To

Dynamics 365 Business Central online and on-premises, current and recent AL versions. Table numbers in the base app are stable, but confirm in your own environment with the Table Information page or the symbols.

## Steps

### How to work with these tables in AL

**Items:**

- Find the table in your environment: search for Table Information or open the base app symbols in VS Code and look up the object by number or name.
- Read from the Item table (27) by record: declare Item: Record Item, set filters on No., Blocked or Inventory Posting Group, then call FindSet and loop.
- For stock quantities, do not read a stored field: Inventory is a FlowField, so call CalcFields(Inventory) before using it.
- To inspect item tracking links, look at Item Entry Relation (6507), which connects a source document line to the item ledger entries created for it, plus Item Ledger Entry (32) for the entries themselves.
- When you need a working set that must not hit the database, declare a temporary record: TempItem: Record Item temporary;.
- Fill it with Insert, loop it, and bind it to a page by setting SourceTableTemporary = true on the page.
- Remember temporary data disappears when the variable goes out of scope. Copy results to real tables only through the proper posting routines.
- Test with several companies and data volumes, since filters and FlowFields behave differently with larger data.

## Sections

### The Item table (27) in practice

**Body:**

The Item table holds the item master: No., Description, Base Unit of Measure, Inventory Posting Group, Costing Method, Unit Cost, Unit Price, Replenishment System, Reordering Policy and many more. It is linked to Item Ledger Entry (32) and Value Entry (5802) for quantity and cost, and to Item Unit of Measure, Item Variant and Item Substitution for variations.

Quantities are mostly FlowFields calculated from item ledger entries, such as Inventory, Net Change, Qty. on Sales Order and Qty. on Purch. Order. They return zero until CalcFields runs in code, which is a frequent source of why does my item show no stock bugs.

Do not modify posted data. Changing Item fields such as Costing Method after entries exist is blocked or restricted, because the cost history depends on it. Use the standard pages and posting routines rather than direct Modify calls on ledger tables.

**Code:**

var
    Item: Record Item;
begin
    Item.SetRange(Blocked, false);
    if Item.FindSet() then
        repeat
            Item.CalcFields(Inventory);
            if Item.Inventory < 0 then
                Message('Negative stock on %1', Item."No.");
        until Item.Next() = 0;
end;

### What table 6507 is, and the tracking tables around it

**Body:**

People often search for table 6507 expecting the tracking spec. In the base app, 6507 is Item Entry Relation, which stores which item ledger entries belong to which source document line, for example a posted purchase receipt line and the lot or serial entries created from it. Its sibling, Value Entry Relation, links value entries.

Item tracking while a document is open uses Reservation Entry (337) for stored lines, and Tracking Specification (336), which the item tracking lines page uses as a temporary table. Lot No. Information and Serial No. Information (6505 and 6504 in the base app) hold master data for tracked numbers.

Table numbers are a convenience, not a contract. If you build an extension, reference tables by name (Record "Item Entry Relation") rather than by number, so symbols keep the dependency readable and checked at compile time.

### How temporary tables work in AL

**Body:**

A temporary record has the same fields and keys as a real table but lives only in memory for the lifetime of the variable. Insert, Modify, Delete and FindSet all work, but nothing is written to the database and no locking or database transaction applies. Table triggers run only if you ask, as with Insert(true).

Typical uses are building a result set for a page or report, aggregating data for an API, buffering import lines for validation, and holding the Tracking Specification lines during an item tracking dialog. Pages with SourceTableTemporary = true or tables with TableType = Temporary behave the same way.

A temporary table that receives a rec copy of the real table needs a deliberate loop, since assignment of a temporary variable to a real record copies field values only for the single current record.

**Code:**

var
    TempItem: Record Item temporary;
    Item: Record Item;
begin
    Item.SetRange("Inventory Posting Group", 'RESALE');
    if Item.FindSet() then
        repeat
            TempItem := Item;
            TempItem.Insert();
        until Item.Next() = 0;
    // TempItem now holds an in-memory copy, nothing written to the DB
end;

### Performance and troubleshooting

**Body:**

Use SetLoadFields before FindSet on Item when you need only a few fields, and use SetCurrentKey with matching filters so the SQL engine uses an index. Wide tables like Item are expensive to read in full inside loops.

A common mistake is calling Rec.Insert on a temporary variable with the primary key unset, which raises a duplicate or empty key error. Another is expecting a temporary record to see changes made later in the database. Remember too that on a page with a temporary source table, the standard actions work on the in-memory copy.

## Pitfalls

- Reading Inventory or other FlowFields without CalcFields and concluding the item has no stock.
- Assuming table 6507 is the tracking specification, when it is Item Entry Relation and the tracking spec is table 336.
- Using table numbers instead of names in extension code, reducing readability and symbol checking.
- Expecting a temporary record to persist or to be visible to other sessions after the variable goes out of scope.
- Modifying ledger or relation tables directly instead of using standard posting routines.

## Ai Angle

For Business Central, a private AI layer can answer questions like which items have negative inventory or which lot numbers came in on a posted receipt by querying the Item, Item Ledger Entry and Item Entry Relation data read-only through the API or a replica, showing the query it used. For AL development work, it can also draft the CalcFields and SetLoadFields loops, which a developer reviews before use.

## Faq

### What is the Business Central item table number?

**Answer:** The Item table is table 27 in the base application. Related tables include Item Ledger Entry (32), Value Entry (5802), Item Unit of Measure (5404) and Item Variant (5401). Confirm the numbers in your environment through the Table Information page or the symbols in VS Code.

### What is table 6507 in Business Central?

**Answer:** In the base application, table 6507 is Item Entry Relation, which links a source document line to the item ledger entries created from it. Tracking Specification is table 336 and Reservation Entry is table 337. Verify in your own version.

### How do I create a temporary table in AL?

**Answer:** Declare a record variable with the temporary keyword, for example TempItem: Record Item temporary, or set the TableType property of your own table to Temporary. It lives in memory only and is discarded when the variable goes out of scope.

### Why does Item.Inventory show zero in my code?

**Answer:** Inventory is a FlowField, so it is calculated only when you call CalcFields(Inventory) on the record, or when a page calculates it for display. Without that call, the value stays zero.

## Search terms

business central item table, business central table 27, business central table 6507, item entry relation business central, business central temporary table, al temporary record, tracking specification table 336, business central item ledger entry, sourcetabletemporary, calcfields inventory business central

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
