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 Line No. is populated in Sales Line Table for any Document Type?

(0) ShareShare
ReportReport
Posted on by 607

Hi All,

Using code I wanted to create a Sales Line record for Document type = Quote against a particular "No.", but i am not able to understand how "Line No." is handeled in Sales Line by the standard. So manually created a couple Sales Quote with few items attached to it, and it noticed in the Sales Line table that for each item record for their Quote No. , Line No. = 1000, and for further items  Line No. = 2000,3000,and so on

Is this true?

Thanks in Advance

I have the same question (0)
  • Satyajit Barik Profile Picture
    7 on at
    RE: How Line No. is populated in Sales Line Table for any Document Type?

    thank you sir

    we were trying to resolve this problem for last 3 weeks

  • AXBOY Profile Picture
    607 on at
    RE: How Line No. is populated in Sales Line Table for any Document Type?

    Thank you all so much! :)

  • Verified answer
    Daniel Rimmelzwaan Profile Picture
    3,485 on at
    RE: How Line No. is populated in Sales Line Table for any Document Type?

    It's a design pattern in the app. You will find a lot of places where there is a parent-child relationship between two tables, and the 'child' table has a compound primary key that ends with an Integer type field called "Line No.". Examples are Purchase Header and Purchase Line, Sales Header and Sales Line, but also the Journal Line tables like General Journal Line and Item Journal Line.

    In code, you have to take care of the "Line No." values yourself by incrementing them by 10,000. It doesn't really matter, you can increment them by whatever value you want, it is not relevant. The reason why there is an increment of 10,000 in the standard app is that way there is room to insert records between existing ones.

    The numbers in the app are automatically generated by the page object. Look at the standard Sales Order page (page number 42) and the Sales Order Subform page (page number 46). The PK on the Sales Header table is "Document Type" and "No.", and the PK on the Sales Line is "Document Type", "No.", and "Line No.". The subform page is a part control on the sales order page called "SalesLines" and it points to the "Sales Order Subform" with a link between the two. The link is on the "No." field (the subform has a filter on Document Type = Order).

    From the standard "Sales Order" page:

    pastedimage1589384607080v3.png

    The property that sets the line number is 'AutoSplitKey'. Another important property is DelayedInsert. Normally a page will insert the record as soon as the PK fields are entered, DelayedInsert causes the page to wait until you move away from the record.

    pastedimage1589384582548v2.png

    AutoSplitKey sets the "Line No." field to the next 10,000 when you add a new one at the bottom of the screen. When you insert a record between two existing ones, it will split the difference. So if you insert one between 10,000 and 20,000, it will set the line number to 15,000. You can insert 13 lines like that until the difference is too small to split 

    To make AutoSplitKey work, you must have a compound PK on the 'child' table where the last field is an integer field. It won't work if the integer field is not the last field.

  • Verified answer
    Genie Cetas Profile Picture
    472 on at
    RE: How Line No. is populated in Sales Line Table for any Document Type?

    Hi,

    In Sales Order if you create any Sales line the Line No will be automatically created like 10000,20000..etc..., it is default, how its happens means in sales order subform page(46) you can find a property named as AutoSplitKey, in default its should be Yes and also in Sales Line Table(37) the Line No. field as a Primary key and its should be the Last Primary Key also in Sales Line Table.

    This AutoSplitKey work while you are entering data through in Page only. if you want to create any sales order by coding the AutoSplitKey will not work because You are directly inserting data in Table there you have to manually insert the Line Number one by one, because you are inserting each data by coding so you have to manually insert the Line No. also like 10000,20000... Etc...

    Sales Line Table

    --------------------------------

    Sales-Line-Table.PNG

    Sales Order SubForm Page:-

    ------------------------------------------------

    Sales-Order-SubForm-Page.PNG

  • Verified answer
    Salah Eddine BENOUALA Profile Picture
    485 on at
    RE: How Line No. is populated in Sales Line Table for any Document Type?

    Hi AXBOY,

    The approach is true, you should just pay attention for the step : 10000 instead of 1000.

    Then you have lines starting with 10000,20000,30000, ... and so on.


    -----------------------------------------

    Best Regards,

    Salah Eddine BENOUALA

    Dynamics NAV & 365 Business Central Consultant

    Please verify my answer, if you find it helpful.

    Doing so you'll show others that there was found a solution and you credit my 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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
Nimsara Jayathilaka. Profile Picture

Nimsara Jayathilaka. 3,885

#2
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 3,405

#3
Sumit Singh Profile Picture

Sumit Singh 2,837

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans