Sales Sub Line

RoelofRoelof Member Posts: 377
I need some help on this one.
I need to find a trigger what gives me the 'Line No.' if I'm creating a new SalesLine, with form property: DelayedInsert = True.
The problem what I have is that Navision doesn't have the 'Line No.' available at the time that you create a new salesline with Delayed insert = true. The line will only be created if you go to the next line.
I need the lineNo field in order to create a Subline, attached to the salesline.
I tried triggers in the SalesLine form aswell. Just nothing works.

Please help.

Thanks,
Roelof de Jong.
Roelof de Jonghttp://www.wye.com

Comments

  • Alex_ChowAlex_Chow Member Posts: 5,063
    Hello,

    Please check the AutoSplitKey on the form property. Make sure it's set to YES.

    Also, make sure the Line No. is the last key on your primary key.
  • fbfb Member Posts: 246
    The following triggers can 'see' the new Line No:
    • Sales Order Subform -- OnInsertRecord
    • Sales Line Table -- OnInsert
    If you add code to the form's OnInsertRecord trigger, be sure to EXIT(TRUE) if you want the usual insert behavior to continue. Otherwise, the form will assume that you have inserted the record on your own.
  • RoelofRoelof Member Posts: 377
    Hi FB,

    You are awesome.
    That did the trick. I wish we as Navision programmers could update our skills with tips and tricks like this. There are actually so many things we just don't know.

    Thanks again!

    Kind regards,
    Roelof de Jong.
    Roelof de Jonghttp://www.wye.com
  • ajhvdbajhvdb Member Posts: 672
    What did the trick exactly? Does this really work?
  • RoelofRoelof Member Posts: 377
    ajhvdb,

    Yes, it really works. What happens is that, if you set DelayedInsert = true, Navision is not immediateley inserting a new record when you enter data on a line. If you add some code to the OnInsert trigger of the form with an Exit(true) it will immediately save the line when you fire some code in that trigger. So, I was able to insert my subline, based on the key: DocType,DocNo,LineNo,SubLine.

    I hope this helps.
    Roelof de Jonghttp://www.wye.com
Sign In or Register to comment.