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

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

How to set Sr no automatic.

(0) ShareShare
ReportReport
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

I have the same question (0)
  • Suggested answer
    Nitin Verma Profile Picture
    21,698 Moderator 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

  • Suggested answer
    Nilam Bhor Profile Picture
    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
    21,698 Moderator 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;
    ;
  • Nilam Bhor Profile Picture
    153 on at
    RE: How to set Sr no automatic.

    Thank you .It works.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,377

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 2,696 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,512 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans