---
id: post/yzhums-com/31884
type: post
title: "Dynamics 365 Business Central: Quickly get next Sequence/Entry Number (without using FindLast -> Entry No. + 1)"
summary: The post explains how to retrieve the next sequence or entry number for ledger tables in Business Central using the Sequence No. Mgt. codeunit instead of the traditional FindLast() + 1 approach. This provides a cleaner, standard pattern for generating primary keys in ledger tables.
tier: community
language: en
tags:
  - sequence numbers
  - entry numbers
  - ledger tables
  - primary keys
  - codeunits
  - al development
system: development
review:
  state: reviewed
  by: opus
  at: "2026-10-26T06:42:21.264Z"
  flags: []
generated:
  at: "2026-10-26T05:51:10.938Z"
  pipeline: 0.2.0
  prompts:
    extract-post: 1
  input_hash: 3dae3b359386ca6cf5c3fdbff2405d2cd3077d34248b4728f7d500ae146fa12a
evidence:
  - kind: blog
    url: https://yzhums.com/31884/
    title: "Dynamics 365 Business Central: Quickly get next Sequence/Entry Number (without using FindLast -> Entry No. + 1)"
    date: "2025-08-20"
    commit: null
    t: null
    quote: null
  - kind: blog
    url: https://yzhums.com/31884/
    title: "Dynamics 365 Business Central: Quickly get next Sequence/Entry Number (without using FindLast -> Entry No. + 1)"
    date: "2025-08-20"
    commit: null
    t: null
    quote: If the table primary key passed in is not Integer Data Type, a runtime error will occur.
links:
  learn: []
  objects:
    - object/table/18
    - object/table/37
    - object/table/32
    - object/table/17
    - object/table/5802
    - object/table/21
    - object/codeunit/9500
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
  related:
    - to: post/mohana-blog/tag-blogger-com-1999-blog-1492436440038408053-post-483274250682537951--01a78739b7
      title: BC 29 lets a single index span base table and table extension fields
      label: possibly related
      why: both name Table 32 "Item Ledger Entry"
      by: code
    - to: post/thatnavguy-com/https-thatnavguy-com-blog-2025-bc-friday-tips-56-understand-missing-fields-in-copy-documents--e98f782aea
      title: "BC Friday Tips #56 Understand Missing Fields in Copy Documents"
      label: possibly related
      why: both name Table 37 "Sales Line"
      by: code
    - to: post/thatnavguy-com/https-thatnavguy-com-blog-2026-bc-friday-tips-84-item-missing-from-sales-line-lookup--ac89a8fbc6
      title: "BC Friday Tips #84 Why Is Your Item Missing from the Sales Line Lookup?"
      label: possibly related
      why: both name Table 37 "Sales Line"
      by: code
    - to: post/yzhums-com/76518
      title: "Business Central 2026 release wave 2 (BC29): AL developers can turn indexes on/off in AL code"
      label: possibly related
      why: both name Table 21 "Cust. Ledger Entry"
      by: code
    - to: video/qABlX4AL3GM
      title: "Business Central 29.0: Major Change to Table Extensions & SQL."
      label: possibly related
      why: both name Table 32 "Item Ledger Entry"
      by: code
    - to: post/kine-cz/https-blog-kine-cz-posts-bcdevelopmentserie-02b--0078d7faba
      title: "Business Central Development Serie - Part 2b: AI for BC Development — The Knowledge Gap That Ships to Production"
      label: possibly related
      why: both name Table 37 "Sales Line"
      by: code
    - to: post/aardvarklabs-blog/1822
      title: "Business Central Queries: Simplifying Complex Data"
      label: possibly related
      why: both name Table 21 "Cust. Ledger Entry"
      by: code
    - to: post/aardvarklabs-blog/1816
      title: Creating Data Driven Text with AI in Business Central
      label: possibly related
      why: both name Table 21 "Cust. Ledger Entry"
      by: code
    - to: video/Fk6kWTe3f2Y
      title: Deploy Analysis Views with AL Code in Business Central 2026 Wave 1 (No Manual Setup)
      label: possibly related
      why: both name Table 32 "Item Ledger Entry"
      by: code
    - to: post/thedynamicsexplorer-com/10326
      title: Dynamics 365 Business Central – How to post a Sales Credit for an Item without affecting Inventory using an Item Charge
      label: possibly related
      why: both name Table 5802 "Value Entry"
      by: code
post_id: "31884"
source_id: yzhums-com
source_name: Dynamics 365 Lab - Yun Zhu
url: https://yzhums.com/31884/
published_at: "2025-08-20T00:48:27.000Z"
author: Yun Zhu
full_text: false
words: 479
quotes:
  - text: If the table primary key passed in is not Integer Data Type, a runtime error will occur.
    why_it_matters: Critical constraint that developers must understand to avoid runtime failures when using the codeunit
code_objects_mentioned:
  - table Customer
  - table Sales Line
  - table Item Ledger Entry
  - table G/L Entry
  - table Value Entry
  - table Cust. Ledger Entry
  - codeunit Sequence No. Mgt.
  - codeunit NoSeriesManagement
systems:
  - development
  - finance
versions_mentioned: []
cautions:
  - kind: warning
    quote: If the table primary key passed in is not Integer Data Type, a runtime error will occur.
    objects:
      - type: codeunit
        name: Sequence No. Mgt.
    events: []
    versions: []
preview:
  embeddable: true
  frame_url: null
  image: https://yzhums.com/wp-content/uploads/2025/08/Snipaste_2025-08-20_09-24-57.png
  image_alt: null
  image_w: null
  image_h: null
  site_name: Dynamics 365 Lab
  favicon: https://yzhums.com/wp-content/uploads/2020/08/cropped-logo-3-32x32.png
  probed_at: "2026-10-26T06:16:29.354Z"
---

# Dynamics 365 Business Central: Quickly get next Sequence/Entry Number (without using FindLast -> Entry No. + 1)

[Read the post](https://yzhums.com/31884/) · Dynamics 365 Lab - Yun Zhu (Yun Zhu, MVP) · 2025-08-20 · 479 words · tier community · reviewed (checked by Opus)

> The post explains how to retrieve the next sequence or entry number for ledger tables in Business Central using the Sequence No. Mgt. codeunit instead of the traditional FindLast() + 1 approach. This provides a cleaner, standard pattern for generating primary keys in ledger tables.

## Key points

- Business Central supports three methods for generating primary keys: No. Series, AutoSplitKey property, and finding the last number then adding 1
- Ledger tables use integer Entry No. fields that are automatically incremented, requiring sequence number generation when adding custom data
- Codeunit 9500 'Sequence No. Mgt.' provides procedures GetNextSeqNo() and GetCurrentSeqNo() that simplify retrieving sequence numbers without manual FindLast() logic
- The sequence codeunit accepts only tables with integer primary keys; non-integer keys will cause runtime errors
- Using LockTable() before FindLast() may be necessary to prevent simultaneous insertion conflicts

## Quotes

- "If the table primary key passed in is not Integer Data Type, a runtime error will occur." (Critical constraint that developers must understand to avoid runtime failures when using the codeunit)

## AL objects mentioned

As named in the post. A name that matches one object page by exact type and name links to it; the others stay as named.

- [table 18 "Customer"](../../objects/table/18.md)
- [table 37 "Sales Line"](../../objects/table/37.md)
- [table 32 "Item Ledger Entry"](../../objects/table/32.md)
- [table 17 "G/L Entry"](../../objects/table/17.md)
- [table 5802 "Value Entry"](../../objects/table/5802.md)
- [table 21 "Cust. Ledger Entry"](../../objects/table/21.md)
- [codeunit 9500 "Sequence No. Mgt."](../../objects/codeunit/9500.md)
- codeunit "NoSeriesManagement"

Not found in BC28-30: codeunit "NoSeriesManagement".

## Possibly related

No source states these links: they share an object, a model read them, or a person found the same subject.

- [BC 29 lets a single index span base table and table extension fields](../../posts/mohana-blog/tag-blogger-com-1999-blog-1492436440038408053-post-483274250682537951--01a78739b7.md) — possibly related: both name Table 32 "Item Ledger Entry"
- [BC Friday Tips #56 Understand Missing Fields in Copy Documents](../../posts/thatnavguy-com/https-thatnavguy-com-blog-2025-bc-friday-tips-56-understand-missing-fields-in-copy-documents--e98f782aea.md) — possibly related: both name Table 37 "Sales Line"
- [BC Friday Tips #84 Why Is Your Item Missing from the Sales Line Lookup?](../../posts/thatnavguy-com/https-thatnavguy-com-blog-2026-bc-friday-tips-84-item-missing-from-sales-line-lookup--ac89a8fbc6.md) — possibly related: both name Table 37 "Sales Line"
- [Business Central 2026 release wave 2 (BC29): AL developers can turn indexes on/off in AL code](../../posts/yzhums-com/76518.md) — possibly related: both name Table 21 "Cust. Ledger Entry"
- [Business Central 29.0: Major Change to Table Extensions & SQL.](../../videos/qABlX4AL3GM.md) — possibly related: both name Table 32 "Item Ledger Entry"
- [Business Central Development Serie - Part 2b: AI for BC Development — The Knowledge Gap That Ships to Production](../../posts/kine-cz/https-blog-kine-cz-posts-bcdevelopmentserie-02b--0078d7faba.md) — possibly related: both name Table 37 "Sales Line"
- [Business Central Queries: Simplifying Complex Data](../../posts/aardvarklabs-blog/1822.md) — possibly related: both name Table 21 "Cust. Ledger Entry"
- [Creating Data Driven Text with AI in Business Central](../../posts/aardvarklabs-blog/1816.md) — possibly related: both name Table 21 "Cust. Ledger Entry"
- [Deploy Analysis Views with AL Code in Business Central 2026 Wave 1 (No Manual Setup)](../../videos/Fk6kWTe3f2Y.md) — possibly related: both name Table 32 "Item Ledger Entry"
- [Dynamics 365 Business Central – How to post a Sales Credit for an Item without affecting Inventory using an Item Charge](../../posts/thedynamicsexplorer-com/10326.md) — possibly related: both name Table 5802 "Value Entry"

## Heads up

- warning: "If the table primary key passed in is not Integer Data Type, a runtime error will occur." (about codeunit Sequence No. Mgt.)

## Context

- Features: No. Series module, AutoSplitKey property, Sequence number management, Entry number generation, GetNextSeqNo procedure, GetCurrentSeqNo procedure

Source: Dynamics 365 Lab - Yun Zhu, community blog. Summary, key points and quotes are derived (CONTENT-NOTICE.md); read the original for the full text.
