CurrPage.SAVERECORD error

veerendraveerendra Member Posts: 66
edited 2013-05-31 in NAV Three Tier
Hi,

Please read the http://www.mibuso.com/forum/viewtopic.php?f=23&t=13592&start=0 post. The same code is working in the forms but I added same code in page OnValidate but it is giving me an error "The Sales Line already exist. Identification fields and values: Document Type='Order', Document No.='xxxx',Line No.='10000'

No. OnValidate()
CurrPage.SAVERECORD;
MESSAGE('%1',"Line No.");

Is that means SAVERECORD will not work if the record is not inserted completely?

#-o
Veerendra Ch.
http://midynav.blogspot.com/ (Microsoft Dynamics Navision)

Comments

  • krikikriki Member, Moderator Posts: 9,112
    Have you tried to put the code in the OnAfterValidate-trigger?
    The OnValidate-trigger serves to check if the input is valid.
    The OnAfterValidate-trigger is more for saving some info.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Jens_M-PJens_M-P Member, Microsoft Employee Posts: 39
    Am I right in assuming that you have changed the code in the No. - OnValidate trigger in Page 46 - Sales Order Subform.
    I have tried this out in the SP1 standard application - and I do not see the behavior you are describing.

    Do you have code in the OnInsertRecord trigger on the page (which will get called by the SAVERECORD? It would be interesting to know what the value of the line no. field is in that trigger.
    Did you change the AutoSplitKey, DelayedInsert or MultipleNewLines properties?
    Best regards,
    Jens Møller-Pedersen [MSFT]

    This posting is provided 'AS IS' with no warranties, and confers no rights.
  • Vincent_VancalberghVincent_Vancalbergh Member Posts: 10
    I had this issue as well. A SAVERECORD that seemed standard NAV 2009 triggered an error when the moment when an INSERT would occur automatically. Now, in my opinion, this is a bug. When the record is already saved in this way, the client/service should be aware of that and do a MODIFY instead. Consistent with the behavior of the Classic runtime. It's this behavior that prevents the construction of a fake "OnAfterInsert" trigger in a Table Object:

    OnInsert()
    BEGIN
    //some code here
    INSERT;
    //some code here that can calculate things like a total on a parent record as if the current record was already inserted (because.. it is)
    DELETE; //needed to prevent a duplicate key error
    END

    The above worked in the Classic runtime. Doesn't work in RTC runtime.

    However, the situation being what it is, as Jens suggested I checked DelayedInsert. It was "Yes". Setting it to "No" caused the record to already be inserted before the trigger that does SAVERECORD goes off. So the SAVERECORD does a MODIFY instead of an INSERT --> issue avoided.

    --> This is a workaround, not a fix

    I hope MS fixes this in a future release (and adds a real "OnAfterInsert" trigger on record level :) )
    Senior Technical Consultant at Edan Business Solutions/Sphinx IT
    Owner of V-Kwadraat (see my blog about Programming and my feed about Gaming!)
Sign In or Register to comment.