Insert new lines

bcdeveloperbcdeveloper Member Posts: 3
edited 2020-01-30 in NAV Tips & Tricks
4gnyg3tgmeqy.png
I need to insert new lines in order. The order line has a field called 'suborder code' and I need to insert a line per 'suborder code'.

To achieve this I created a key in the order line table with (suborder code, line no).
Then created a processing report. In the processing report, I added the order line table and add sort by the new key.

I wrote the code to insert a line at the last of the table but I want to insert a new line every time when 'suborder code' is change.


Thank you!

Answers

  • kelgenkelgen Member Posts: 1
    Hey BCDeveloper,

    When looping through your record set store your Code in a variable.
    When your old Code <> Current Code, FindLast on your table with the old SubOrder Code and Insert a new Line.

    Hope this helps.

    BR,
    KG
  • sradouan@hotmail.comsradouan@hotmail.com Member Posts: 11
    Hi BCDeveloper,

    You can use select distinct with List variable,like this sample.

    procedure RetrieveNames()
    var
    customer: record Customer;
    customerNamesList: List of [Text];

    begin
    if customer.FindSet() then
    repeat
    begin
    if not customerNamesList.Contains(customer.Name) then
    customerNamesList.Add(customer.Name);
    end
    until customer.Next = 0;

    foreach name in customerNamesList do
    Message(name); //use your inser function

    end;

    Thanks.
Sign In or Register to comment.