Options

Autosplitkey and delayed insert

Pieter_GoversPieter_Govers Member Posts: 6
I have a problem with the sales lines and a own created table.

The situation is as follow:
Order form (sales header and sales lines table)
- Default on the sales line subform the autosplitkey is true for "Line No." also the property "delayed insert" is default set to yes. (this must stay so because otherwise the focus goes to the subform)
- Now the problem is on the onvalidate trigger of the quantity, I must add some lines to a own created table and this table contains also the "document type", "document No.", "Line No." form the sales line table. But everytime i does this the line number is still on '0'. This is because the delayed insert, the record is'nt saved yet and there is no splitkey generated yet. How can i force (in code) to generate the splitkey to copie to my table?

Kind regards,

Pieter

Answers

  • Options
    Miklos_HollenderMiklos_Hollender Member Posts: 1,598
    Try moving your code to OnAfterValidate and issue a CurrForm.Update(TRUE) before it.
  • Options
    WaldoWaldo Member Posts: 3,412
    And also see if "xRec.Quantity <> Rec.Quantity"

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • Options
    ajhvdbajhvdb Member Posts: 672
    `...and please let us know if this solved your problem :) i'm very interested.
  • Options
    kinekine Member Posts: 12,562
    Check the functions which are adding dimensions to the line. It is same, the dimensions are written into another table and are connected through Line No., but they are added in OnValidate (for example on No. field). You can do it in same way.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    Pieter_GoversPieter_Govers Member Posts: 6
    Problem solved!

    I've created a function that run on the "Sales Line" table ("Oninsert", "OnModify" and "OnDelete" trigger) when "xRec.Quantity <> Rec.Quantity", in this function I run my code and is the "Line No." filled in.

    Thanks
  • Options
    WaldoWaldo Member Posts: 3,412
    You know, Kine gives a great tip there...
    When doing development, always try to find a similar piece of fuctionality in default NAV, see how they solved it ... and try to use the same method.

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • Options
    gulamdastagirgulamdastagir Member Posts: 411
    Waldo wrote:
    And also see if "xRec.Quantity <> Rec.Quantity"

    please can you tell me the mystery behind this "xrec<>rec",i have seen it used so many places!
    Regards,

    GD
  • Options
    kinekine Member Posts: 12,562
    It is not mystery, xrec is record before change (how it is now saved in DB), rec is actual record (with the modification) which you are going to save into DB.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    gulamdastagirgulamdastagir Member Posts: 411
    kine wrote:
    It is not mystery, xrec is record before change (how it is now saved in DB), rec is actual record (with the modification) which you are going to save into DB.

    i know this ,i want to know at the database level,how does Navision actually do this comparison,does it use any buffers and where does it store them,the Technical details please
    Regards,

    GD
  • Options
    WaldoWaldo Member Posts: 3,412
    It is actually a consequence of the versioning principle that NAV applies. It always has the version you read in cache to compare if it was changed.

    C/SIDE makes this version available to you (it is not an extra database call).

    You should do the comparison, to avoid to make unnecessary database calls.

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
Sign In or Register to comment.