Show the Line No. of the line above


I think I’ll never understand how navision does it work !!!

I explain you my problem :

I have 2 sales line in my order, i’d like to add a third sales line between them and when I validate the description field, I have to show the Line No. of the live above !

Example :

Step 1:

Line Type No. Description

10000 Item N001 D1

20000 Item N002 D2

Step 2: Insert a new line between the lines above

Line Type No. Description

10000 Item N001 D1

15000 Item N003 D3 << When I validate “D3” I’d like to show message 10000 (Line No. of line above)

20000 Item N002 D2

I tried several alternatives, the problem is when I validate the description field, I have not yet the Line No. so I did my code in on insert record trigger of the page. (my code Below)


G_PrevSalesLine.GET(“Document Type”,“Document No.”,xRec.“Line No.”);

IF G_PrevSalesLine.NEXT(-1) <> 0 THEN

MESSAGE(‘previous line is : %1’, xRec.“Line No.”);


The problem is when I delete the record I don’t obtain the good result !!!

How can resolve it ?

Thank’s for your help

Can I ask why you need this?

If you have the field visible thn what’s the need of a “message?”

Yes I know :slight_smile:

In fact, I have to attache the last line created to the firste line using the field attached to the line No.

I said (show message) just to simplify my question.

The problem with any of that is that it stops working once the user sorts the form differently. I think what needs to happen is if the related line is created by some function, the function should populate that line. You could add a little function to the Line button just to create the related line without any other fields populated. If it’s manual entry, I’d provide a lookup into the line table.

Yes it is a manual entry, How could you make a lookup on this field ? the probleme, when you have several rows for exampl

Line No. Type Attached to Line No.

10000 Item

20000 Item

30000 20000

35000 (I want to attach this line to Line No. 20000)

40000 Item

you can’t do lookup ! my solution is to find the first Item above the line that I want to attach … bu I don’t know how ??! (and the problem here I dont know the Line No. of created line when I do my treatment)

Sure you can, lookup into the sales line table where the document type and document number are equal. In the field’s table relationship property, put in something like:

“Sales Line”.“Line No.” WHERE (Document Type=FIELD(Document Type),Document No.=FIELD(Document No.))

Should work.