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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

I want to add line number(in row as 1,2,3...) in my simple list form D365Fo What is complete procedure to do it?

(0) ShareShare
ReportReport
Posted on by 226

I want to add line number(in row as 1,2,3...) in my simple list form D365Fo What is complete procedure to do it? 

I have the same question (0)
  • Suggested answer
    GirishS Profile Picture
    27,827 Moderator on at

    Hi JJDunaid,

    Refer to the standard TsTimesheetLine table for adding line numbers to the row.

    You need to add a code to set the next line number and also it must be added to the index.

    Refer to the method setNextLineNum method on TsTimesheetLine table which is called in the initValue of the table method.

    Thanks,

    Girish S.

  • JJDunaid Profile Picture
    226 on at

    initvalue(code)my code just shows me 1i want to add line number in a grid of form,  

    whenever i add new line into grid i want it to add it self by 1, e.g (like line number 1,2,3 and so on.....)

    would be easier if you send me code to write in initvalue().

  • Verified answer
    GirishS Profile Picture
    27,827 Moderator on at

    Yes, I understood the issue. You need to create an integer field in the table.

    Override the initValue method of the table and add the below code to increment value of LineNum field whenever new record is created.

    public void initValue()
    {
        YourTableName tableName;
        super();
        select firstonly maxof(LineNum) from tableName;
        this.LineNum = tableName.LineNum   1;
        
    }

    Thanks,

    Girish S.

  • Verified answer
    ergun sahin Profile Picture
    8,826 Moderator on at

    If it is a form that will be used by more than one person or the registration time is long, init may not be the right place (someone else can get the same number until you save it) I think you should write it in the insert

  • JJDunaid Profile Picture
    226 on at

    Ergun Sahin,

    yes it is doing the same as you just told!

    but its just showing me 2 insert methods (insertifempty(),  insertatend())

    which one should i choose and do i have to write same code as i did in initvalue() method?

  • JJDunaid Profile Picture
    226 on at

    yes it did work but when i add new record it adds new record in same row and adds lineNumber in same row

    ,now its not even adding any new record

  • Verified answer
    GirishS Profile Picture
    27,827 Moderator on at

    InsertIfEnd and InsertIfEmpty is the property on the DataSource.

    You need to override the insert method on the table and add the code as you have written on the initValue method.

    What do you mean by "it adds new record in same row and adds lineNumber in same row"?

    If you click on New button on the form, it will create new record in the table - It will not override the existing line.

    Thanks,

    Girish S.

  • JJDunaid Profile Picture
    226 on at

    Girish

    thanks for your help :)

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 584 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 499 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 254 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans