Skip to main content

Notifications

Announcements

No record found.

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:
  • Dynamics 365 Business Central Profile Picture
    700 on at
    RE: Generating random number series

    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

  • Suggested answer
    Suresh Kulla Profile Picture
    47,789 on at
    RE: Generating random number series

    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.

  • Hannes Holst Profile Picture
    5,767 on at
    RE: Generating random number series

    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

  • Dynamics 365 Business Central Profile Picture
    700 on at
    RE: Generating random number series

    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
    RE: Generating random number series

    Sorry, but I don't understand your requirement.

  • Dynamics 365 Business Central Profile Picture
    700 on at
    RE: Generating random number series

    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
    RE: Generating random number series

    Like this?

    StartNo := '00001';

    Randomize(1);

    EndNo := Random(99999);

  • Dynamics 365 Business Central Profile Picture
    700 on at
    RE: Generating random number series

    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
    RE: Generating random number series

    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?

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 forum

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans