Setting values in "Line No." in "Purcahse Line"

Hellow, everybody. Very interesting to me how in “Purchase Line” and “Sales Line” tables field “Line No.” gives the value when inserting new line? I found only one thing: after field “No.” validation field “Line No.” gives new value. Debugger take me on SAVERECORD call at the end of debugging “No.”:OnValidate. Before SAVERECORD “Line No.” have no value (equals to zero) after SAVERECORD debugger leave out from “Line No.”::OnValidate and “Line No.” had new value. I need to assing value in “Line No.” by myself to make specific sorting order for lines in Purcahse/Sales Orders. Please help me by advice: how can I make it? Thank you for your cooperation.

Hello, The value of field “Line no” is generated by a property of Form. “AutoSplikey” This propety use an increment by 10000 for new line Look the copy of Navision Help Use this property to have the system automatically create a key for a new record placed between the current record and the previous record. Applies to Forms Settings The AutoSplitKey settings are: To… Choose… Let the system create a key which will place a new record between the current record and the previous record Yes Prevent the system from creating a key which will place the new record between the current record and the previous record No (default) Comments There are two prerequisites for turning this property on: the current key must be the primary key and the last field in the primary field must be an integer or decimal field. If these conditions are met, you can set this property to Yes.

Hi Alexander! As Fabrice told, the “Line-No.” is set by “AutoSplitKey” … If you need to change the Line-Order, I would NOT recommend to disable the “AutoSplitKey”-Property and set your own Line-Numbers by code. Perhaps you can define a new Field, e.g. “Position No.”, create a secondary key including this field, and sort by this key? Regards, Jörg Joerg A. Stryk Apollo-Optik, IT/ERP

Hello, in these kind of cases the property “AutoSplitKey” in the forms is set to yes - this generates an automatic generation of the value for line no. without any necesity of coding. If you need to assign your Line No. manually do so in the OnNewRecord trigger of the form. Yet it is easier and more recomendable to add a new field “position” to the table and sort by that field (set up a new key) instead of changing the handling of the primary key (Line No. is part of the primary key of Purchase and Sales lines). Hope this helps. Nils

…looks like we answered all at the same time - 3 posts in about 10 min… NOLUG efficiency… Nils