---
id: object/codeunit/9500
type: object
title: Codeunit 9500 "Sequence No. Mgt."
summary: Codeunit 9500 "Sequence No. Mgt." in Base Application (Microsoft.Foundation.NoSeries). 12 public procedures, 3 events. Present since at least BC23, still in BC30, changed in BC25-27, BC29.
tier: official
language: en
tags:
  - codeunit
  - base application
versions:
  introduced: null
  last_changed: "29"
  deprecated: null
review:
  state: derived
  by: null
  at: null
  flags: []
generated:
  at: "2026-10-11T00:31:51.816Z"
  pipeline: 0.2.0
  prompts: {}
  input_hash: 0e17d1d521952a0a579063f3de72ea7e3d3fe95171e4ed785846d6ade1ae1b1f
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Layers/W1/BaseApp/Foundation/NoSeries/SequenceNoMgt.Codeunit.al
    title: src/Layers/W1/BaseApp/Foundation/NoSeries/SequenceNoMgt.Codeunit.al (releases/29.x)
    date: null
    commit: ea08af5ef2d6a9b5c5af4a029288abbe2c883220
    t: null
    quote: null
links:
  learn: []
  objects: []
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
  changes:
    - change/bcapps/9637
object_type: codeunit
object_id: 9500
name: Sequence No. Mgt.
namespace: Microsoft.Foundation.NoSeries
app: Base Application
extends: null
first_version: "23"
last_version: "30"
present_in:
  - "23"
  - "24"
  - "25"
  - "26"
  - "27"
  - "28"
  - "29"
  - "30"
changed_in:
  - "25"
  - "26"
  - "27"
  - "29"
source_major: "29"
obsolete: null
countries: []
ms_search_form_ids: []
counts:
  fields: 0
  procedures: 22
  events: 3
  subscribers: 0
relations:
  out: 0
  referenced_by: 0
  pages: 0
  extended_by: 0
  event_subscribers: 3
  calls: 0
  called_by: 57
  implements: 0
---

# Codeunit 9500 "Sequence No. Mgt."

> Codeunit 9500 "Sequence No. Mgt." in Base Application (Microsoft.Foundation.NoSeries). 12 public procedures, 3 events. Present since at least BC23, still in BC30, changed in BC25-27, BC29.

Base Application · Microsoft.Foundation.NoSeries · BC23-30 · [source at ea08af5e](https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Layers/W1/BaseApp/Foundation/NoSeries/SequenceNoMgt.Codeunit.al) · facts from BC29

## Properties

| Property | Value |
|---|---|
| SingleInstance | true |
| Permissions | tabledata "Sequence No. Preview State" = rid |

## Events published

- `OnPreviewableLedgerEntry(TableNo: Integer; var IsPreviewable: Boolean)` (integration)
  - subscribers: [Codeunit 22 "Item Jnl.-Post Line"](../codeunit/22.md) OnPreviewableLedgerEntry, [Codeunit 5912 "ServLedgEntries-Post"](../codeunit/5912.md) OnPreviewableLedgerEntry, [Codeunit 7301 "Whse. Jnl.-Register Line"](../codeunit/7301.md) OnPreviewableLedgerEntry
- `OnBeforeGetLastEntryNoFromTable(TableNo: Integer)` (integration): Integration event raised at the beginning of GetLastEntryNoFromTable, before the table is opened. Allows extensions to remove filters (for example global dimension filters) that could affect the last entry number lookup.
- `OnAfterGetLastEntryNoFromTable(TableNo: Integer)` (integration): Integration event raised at the end of GetLastEntryNoFromTable, after the last entry number has been read. Allows extensions to reapply filters that were removed in OnBeforeGetLastEntryNoFromTable.

## Procedures

- `ClearState()`: Clears allocations and other internal states
- `AllocateSeqNoBuffer(TableNo: Integer; NoOfEntries: Integer)`: Allocates sequence numbers for a given table ID. if the sequence does not exist, it will be created.
- `GetNextSeqNo(TableNo: Integer): Integer`: Returns the next buffered NumberSequence value for a given table ID. if the sequence does not exist, it will be created.
- `GetCurrentSeqNo(TableNo: Integer): Integer`: Returns the current NumberSequence value for a given table ID. if the sequence does not exist, it will be created.
- `ValidateSeqNo(TableNo: Integer)`: Ensures that the NumberSequence is not behind the last entry in the table. if the sequence does not exist, it will be created. The result will be cached for the current transaction. The cache can be cleared by calling ClearSequenceNoCheck.
- `ClearSequenceNoCheck()`: Clears the cache that is used by procedure ValidateSeqNo(TableNo).
- `RebaseSeqNo(TableNo: Integer)`: Restarts or recreates the NumberSequence for the specified Table ID.
- `GetTableSequenceName(TableNo: Integer): Text`: Returns the name of the NumberSequence for the specified Table ID.
- `GetTableSequenceName(PreviewMode: Boolean; TableNo: Integer): Text`: Returns the name of the NumberSequence for the specified Table ID. We have one sequence for preview and one for non-preview.
- `StartPreviewMode()` (internal)
- `StopPreviewMode()` (internal)
- `SetPreviewMode(NewPreviewMode: Boolean)` (internal)

Plus 7 local procedures.

## Called by

From the extracted call graph of BC29 (graphify-al on the snapshot checkout): calls whose target is known from a declared type or an `Object::"Name"` argument. Interface dispatch and calls through events are not counted, so the list is not complete.

- [Codeunit 6500 "Item Tracking Management"](../codeunit/6500.md) (3 calls: `CheckWhseItemTrkg → AllocateSeqNoBuffer`, `CreateWhseItemTrackingForReceipt → AllocateSeqNoBuffer`, `InsertWhseItemTrkgLines → AllocateSeqNoBuffer`)
- [Table 1514 "Sent Notification Entry"](../table/1514.md) (3 calls: `InsertRecord → GetNextSeqNo`, `InsertRecord → RebaseSeqNo`, `NewRecord → GetNextSeqNo`)
- [Table 7312 "Warehouse Entry"](../table/7312.md) (3 calls: `GetNextEntryNo → GetNextSeqNo`, `InsertRecord → GetNextSeqNo`, `InsertRecord → RebaseSeqNo`)
- [Codeunit 1012 "Job Jnl.-Post Line"](../codeunit/1012.md) (2 calls: `RunWithCheck → ClearSequenceNoCheck`, `ValidateSequenceNo → ValidateSeqNo`)
- [Codeunit 12 "Gen. Jnl.-Post Line"](../codeunit/12.md) (2 calls: `RunWithCheck → ClearSequenceNoCheck`, `ValidateSequenceNo → ValidateSeqNo`)
- [Codeunit 212 "Res. Jnl.-Post Line"](../codeunit/212.md) (2 calls: `RunWithCheck → ClearSequenceNoCheck`, `ValidateSequenceNo → ValidateSeqNo`)
- [Codeunit 22 "Item Jnl.-Post Line"](../codeunit/22.md) (2 calls: `RunWithCheck → ClearSequenceNoCheck`, `ValidateSequenceNo → ValidateSeqNo`)
- [Codeunit 5051 "SegManagement"](../codeunit/5051.md) (2 calls: `LogInteraction → GetNextSeqNo`, `LogSegment → GetNextSeqNo`)
- [Codeunit 5763 "Whse.-Post Shipment"](../codeunit/5763.md) (2 calls: `Code → SetPreviewMode`, `OnRun → SetPreviewMode`)
- [Codeunit 80 "Sales-Post"](../codeunit/80.md) (2 calls: `CheckSalesLines → AllocateSeqNoBuffer`, `RunWithCheck → SetPreviewMode`)
- [Codeunit 90 "Purch.-Post"](../codeunit/90.md) (2 calls: `CheckPurchLines → AllocateSeqNoBuffer`, `RunWithCheck → SetPreviewMode`)
- [Codeunit 99000891 "Mfg. Item Tracking Mgt."](../codeunit/99000891.md) (2 calls: `CreateWhseItemTrackingForProdOrderLine → AllocateSeqNoBuffer`, `InsertWhseItemTrkgLinesForProdOrderLine → AllocateSeqNoBuffer`)
- [Table 5062 "Attachment"](../table/5062.md) (2 calls: `InsertRecord → GetNextSeqNo`, `InsertRecord → RebaseSeqNo`)
- [Table 5065 "Interaction Log Entry"](../table/5065.md) (2 calls: `InsertRecord → GetNextSeqNo`, `InsertRecord → RebaseSeqNo`)
- [Table 7313 "Warehouse Register"](../table/7313.md) (2 calls: `InsertRecord → GetNextSeqNo`, `InsertRecord → RebaseSeqNo`)
- [Codeunit 1021 "Job Jnl.-Post"](../codeunit/1021.md) (1 call: `OnRun → SetPreviewMode`)
- [Codeunit 19 "Gen. Jnl.-Post Preview"](../codeunit/19.md) (1 call: `PreviewStart → StopPreviewMode`)
- [Codeunit 224 "EmplEntry-Apply Posted Entries"](../codeunit/224.md) (1 call: `OnRun → SetPreviewMode`)
- [Codeunit 226 "CustEntry-Apply Posted Entries"](../codeunit/226.md) (1 call: `OnRun → SetPreviewMode`)
- [Codeunit 227 "VendEntry-Apply Posted Entries"](../codeunit/227.md) (1 call: `OnRun → SetPreviewMode`)
- [Codeunit 23 "Item Jnl.-Post Batch"](../codeunit/23.md) (1 call: `CheckLines → AllocateSeqNoBuffer`)
- [Codeunit 231 "Gen. Jnl.-Post"](../codeunit/231.md) (1 call: `OnRun → SetPreviewMode`)
- [Codeunit 241 "Item Jnl.-Post"](../codeunit/241.md) (1 call: `OnRun → SetPreviewMode`)
- [Codeunit 442 "Sales-Post Prepayments"](../codeunit/442.md) (1 call: `OnRun → SetPreviewMode`)
- [Codeunit 444 "Purchase-Post Prepayments"](../codeunit/444.md) (1 call: `OnRun → SetPreviewMode`)
- [Codeunit 5636 "FA. Jnl.-Post"](../codeunit/5636.md) (1 call: `OnRun → SetPreviewMode`)
- [Codeunit 5706 "TransferOrder-Post (Yes/No)"](../codeunit/5706.md) (1 call: `OnRun → SetPreviewMode`)
- [Codeunit 5760 "Whse.-Post Receipt"](../codeunit/5760.md) (1 call: `OnRun → SetPreviewMode`)
- [Codeunit 5853 "Invt. Doc.-Post (Yes/No)"](../codeunit/5853.md) (1 call: `OnRun → SetPreviewMode`)
- [Codeunit 5884 "Phys. Invt. Order-Post"](../codeunit/5884.md) (1 call: `OnRun → SetPreviewMode`)
- [Codeunit 5912 "ServLedgEntries-Post"](../codeunit/5912.md) (1 call: `InitServiceRegister → ClearSequenceNoCheck`)
- [Codeunit 5940 "ServContractManagement"](../codeunit/5940.md) (1 call: `InitCodeUnit → ClearSequenceNoCheck`)
- [Codeunit 5981 "Service-Post (Yes/No)"](../codeunit/5981.md) (1 call: `OnRun → SetPreviewMode`)
- [Codeunit 699 "Exch. Rate Adjmt. Process"](../codeunit/699.md) (1 call: `OnRun → SetPreviewMode`)
- [Codeunit 7301 "Whse. Jnl.-Register Line"](../codeunit/7301.md) (1 call: `ValidateSequenceNo → ValidateSeqNo`)
- [Codeunit 7304 "Whse. Jnl.-Register Batch"](../codeunit/7304.md) (1 call: `Code → AllocateSeqNoBuffer`)
- [Codeunit 7323 "Whse.-Act.-Post (Yes/No)"](../codeunit/7323.md) (1 call: `OnRun → SetPreviewMode`)
- [Codeunit 900 "Assembly-Post"](../codeunit/900.md) (1 call: `OnRun → SetPreviewMode`)
- [Codeunit 980 "Payment Registration Mgt."](../codeunit/980.md) (1 call: `OnRun → SetPreviewMode`)
- [Table 169 "Job Ledger Entry"](../table/169.md) (1 call: `GetNextEntryNo → GetNextSeqNo`)
- [Table 17 "G/L Entry"](../table/17.md) (1 call: `GetNextEntryNo → GetNextSeqNo`)
- [Table 203 "Res. Ledger Entry"](../table/203.md) (1 call: `GetNextEntryNo → GetNextSeqNo`)
- [Table 281 "Phys. Inventory Ledger Entry"](../table/281.md) (1 call: `GetNextEntryNo → GetNextSeqNo`)
- [Table 32 "Item Ledger Entry"](../table/32.md) (1 call: `GetNextEntryNo → GetNextSeqNo`)
- [Table 339 "Item Application Entry"](../table/339.md) (1 call: `GetNextEntryNo → GetNextSeqNo`)
- [Table 343 "Item Application Entry History"](../table/343.md) (1 call: `GetNextEntryNo → GetNextSeqNo`)
- [Table 45 "G/L Register"](../table/45.md) (1 call: `GetNextEntryNo → GetNextSeqNo`)
- [Table 57 "G/L Transaction"](../table/57.md) (1 call: `GetNextTransactionNo → GetNextSeqNo`)
- [Table 5802 "Value Entry"](../table/5802.md) (1 call: `GetNextEntryNo → GetNextSeqNo`)
- [Table 5832 "Capacity Ledger Entry"](../table/5832.md) (1 call: `GetNextEntryNo → GetNextSeqNo`)
- and 7 more: data/code/graph/29/calls.json

## Recent changes

- 2026-07-24 [#9637 [Event Requests] Add integration events across base app and SMTP module](../../changes/bcapps/9637.md) (main, BC30, feature)

## Across versions

- Present in: BC23-30
- Changed (declaration) in: BC25-27, BC29

Source: AL metadata extracted from the code (names, ids, signatures, properties); no code bodies (D10).

## Ask your agent

Procedure bodies are not stored here (D10). The call sections above are our own, per object, from the BC29 call graph. For a procedure body or the calls of one procedure, ask bc-code-atlas (external, by Stefan Maron, MIT; default corpus w1-28), which the bc-observatory plugin connects: `bcatlas_resolve_node(object_type: "codeunit", object_name: "Sequence No. Mgt.")`, then `bcatlas_get_procedure_body` or `bcatlas_get_neighbors` on the returned id.
