web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Business Central forum

Generating random number series

(0) ShareShare
ReportReport
Posted on by 700

Hi All,

How we can create a random number series in a specific format for a particular field in business central ?

Any AL Code logic !

Thanks.

Categories:
I have the same question (0)
  • Hannes Holst Profile Picture
    5,767 on at

    if you could elaborate your question?

    Do you want to create a random setup for a new no series or do you want to retrieve a random number from an existing setup?

  • Dynamics 365 Business Central Profile Picture
    700 on at

    I want to create a random setup for a new no series for a specific record every time

  • Hannes Holst Profile Picture
    5,767 on at

    Like this?

    StartNo := '00001';

    Randomize(1);

    EndNo := Random(99999);

  • Dynamics 365 Business Central Profile Picture
    700 on at

    Series from E0010 to E9990 is needed to be displayed. Each time, it should be incremented by 1.

  • Hannes Holst Profile Picture
    5,767 on at

    Sorry, but I don't understand your requirement.

  • Dynamics 365 Business Central Profile Picture
    700 on at

    I have a field 'code' in which for every new record, unique code in the format 'E0001' should be generated and for every new record this unique code should be incremented by 1

  • Hannes Holst Profile Picture
    5,767 on at

    So, when creating a new record you want to retrieve the next available number of a No. Series?

    That's not random :-)

    Check function "GetNextNo" of codeunit NoSeriesManagement

    pastedimage1567437441558v1.png

  • Suggested answer
    Suresh Kulla Profile Picture
    50,280 Super User 2026 Season 1 on at

    You just use the No. Series Setup and then use No Series management to retrieve the next No.  Check the standard code for Sales Order, Customer, Item.  You need to add the code in the OnInsert trigger to retrieve the value.

    ex:

    NoSeriesMgt.GetNextNo('Order Nos.", WorkDate, true); Where Order Nos is the setup field, for that review Sales & Receivables Setup... for the Number Series to Setup.

  • Dynamics 365 Business Central Profile Picture
    700 on at

    Is there any way in AL to generate a series for every new record in a particular field. For Ex, I have a field 'Code' in 'Entitlements' page in which I have to generate a series which will be incremented by 1 for every new record

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans