Skip to main content

Notifications

Small and medium business | Business Central, N...
Answered

How to set Sr no automatic.

Posted on by 153

Hii guys,

For example: Here ,My column is sr.no,and this sr.no is a primary key .I write this logic,but I am getting output in sr no start with 0.

I want sr .no starts with 1.

Is there is any way to do this.

pastedimage1676987489638v1.png

  • Nilam Bhor Profile Picture
    Nilam Bhor 153 on at
    RE: How to set Sr no automatic.

    Thank you .It works.

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: How to set Sr no automatic.

    Try below code

      trigger OnInsert()
    var
    YourTable: Record YourTable;
    begin
    "Entry No." := 1;
    YourTable.Reset();
    YourTable.SetRange("Entry No.");
    if YourTable.FindLast() then
    "Entry No." := YourTable."Entry No." + 1;
    end;
    ;
  • Suggested answer
    Nilam Bhor Profile Picture
    Nilam Bhor 153 on at
    RE: How to set Sr no automatic.

    No. Actually I want write a logic for sr no gets automatic.

    We don't want autoincrement property.

    My result is come, but it starts with 0.

    I want number starts with 1.

    pastedimage1676992184836v1.png

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: How to set Sr no automatic.

    Hi,

    You can set field property as per below,

    AutoIncrement=true;

    learn.microsoft.com/.../devenv-autoincrement-property

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,151 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,993 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans