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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Business Central forum

No Series Setup

(0) ShareShare
ReportReport
Posted on by 700

Hi Guys,

How to set up No. Series for a custom field ?

I have created a new code from 'No. Series' and added the table relation to the custom field.

It is allowing to select the code, but the unique code is not getting generated.

Please help !

Thanks.

Categories:
  • Suggested answer
    Avinash B Profile Picture
    1,455 on at

    Hi,

    You have to write a piece of code to fill the value.

    Example: No. field in the Customer table. Generally, the setup will be created to store the no. series code. In the example, In Sales & Receivable setup there is a field called "Customer Nos.", based on which the Customer No. are generated. In order to do this, the code has written on OnInsert trigger of the Customer table. Hence every time new customer has created, the No. field will be generated automatically.

    Please check the below code. The function InitSeries from codeunit NoSeriesManagement will actually do your job.

    IF "No." = '' THEN BEGIN

     SalesSetup.GET;

     SalesSetup.TESTFIELD("Customer Nos.");

     NoSeriesMgt.InitSeries(SalesSetup."Customer Nos.",xRec."No. Series",0D,"No.","No. Series");

    END;

    Regards,

    Avinash B

  • Dynamics 365 Business Central Profile Picture
    700 on at

    Can you please provide me the code in proper format.

    It would be a great help.

    table 50120 EntitlementSetup

    {

       DataClassification = ToBeClassified;

       //DrillDownPageId = Entitlements;

       //LookupPageId = EntitlementSetup;

       fields

       {

           field(1; Code; Code[30])

           {

               DataClassification = ToBeClassified;

               trigger Onvalidate()

               var

                   myInt: Integer;

               begin

               end;

           }

  • Avinash B Profile Picture
    1,455 on at

    Hi

    Could you explain little more like what you want to do here?

  • Dynamics 365 Business Central Profile Picture
    700 on at

    For a new custom field, I want to set up a No. Series. Please tell me the procedure.

  • Dynamics 365 Business Central Profile Picture
    700 on at

    Did you get my query ?

  • Suggested answer
    Avinash B Profile Picture
    1,455 on at

    hi

    Please refer this code.

    ********** Table for the setup **************

    table 50102 "Entitlement Setup"

    {

       DataClassification = ToBeClassified;

       fields

       {

           field(1; "Primary Key"; Code[20])

           {

               DataClassification = ToBeClassified;

           }

           field(2; "Entitlement Nos."; Code[20])

           {

               DataClassification = CustomerContent;

               TableRelation = "No. Series";

           }

       }

       keys

       {

           key(PK; "Primary Key")

           {

               Clustered = true;

           }

       }

       var

           myInt: Integer;

       trigger OnInsert()

       begin

       end;

       trigger OnModify()

       begin

       end;

       trigger OnDelete()

       begin

       end;

       trigger OnRename()

       begin

       end;

    }

    *********** Table for creating the records *************

    table 50103 Entitlements

    {

       DataClassification = ToBeClassified;

       fields

       {

           field(1; Code; Code[20])

           {

               DataClassification = CustomerContent;

               trigger OnValidate()

               begin

                   IF Code <> xRec.Code THEN BEGIN

                       EntitlementSetup.Get();

                       NoSeriesMgt.TestManual(EntitlementSetup."Entitlement Nos.");

                   END;

               end;

           }

           field(2; Description; Text[100])

           {

               DataClassification = CustomerContent;

           }

       }

       keys

       {

           key(PK; Code)

           {

               Clustered = true;

           }

       }

       var

           EntitlementSetup: Record "Entitlement Setup";

           NoSeriesMgt: Codeunit NoSeriesManagement;

           NoSeriesG: Code[20];

       trigger OnInsert()

       begin

           // Value will be filled automatically on insert by getting the next number from the series

           IF Code = '' THEN BEGIN

               EntitlementSetup.GET;

               EntitlementSetup.TESTFIELD("Entitlement Nos.");

               NoSeriesMgt.InitSeries(EntitlementSetup."Entitlement Nos.", '', 0D, Code, NoSeriesG);

           END;

       end;

       trigger OnModify()

       begin

       end;

       trigger OnDelete()

       begin

       end;

       trigger OnRename()

       begin

       end;

    }

    Regards

    Avinash B

  • Dynamics 365 Business Central Profile Picture
    700 on at

    I tried it, sir. It is not working here.

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