Suggest me what is worng in my code while PRINT Report !!

pskannaapskannaa Member Posts: 138
Hi,
I m using NAV 4.0, want to update the STATUS field on my master table while Print the REPORT .

The below code is running fine and show the status message correctly but it's will not update the table...

Status field is dropdown: 0 for pending,1 for working, 2 for completed

Code:

Sales Header - OnAfterGetRecord()

IF CurrReport.PREVIEW = FALSE THEN
BEGIN
recCorrEnq.RESET;
recCorrEnq.SETRANGE("Document No","Sales Header"."Correspondence Reference No");
IF recCorrEnq.FIND('-') THEN
BEGIN
MESSAGE('Before-->Doc No:' + recCorrEnq."Document No"+ ' status:' + FORMAT(recCorrEnq.Status));
recCorrEnq.Status:=2;
recCorrEnq.MODIFY;
MESSAGE('After-->Doc No:' + recCorrEnq."Document No"+ ' status:' + FORMAT(recCorrEnq.Status));
END;
END

Note: output message is fine, NOT UPDATE THE DB TABLE.

Comments

  • garakgarak Member Posts: 3,263
    is the recCorrEnq a other table or also the Sales Header?
    You filter only on the Document No. Exist there are more then one recCorrEnq with this No.?
    Is the PK really only the Document No in recCorrEnq table or also the document Type?
    Do you make it right, it works too!
  • pskannaapskannaa Member Posts: 138
    Hi,
    Thanks for quick reply..

    1. 'recCorrEnq' a other table(which is having STATUS filed)

    2. 'Document No.' is not repeated

    3. 'Document No.' is only Pk filed

    Thanks & Regards,
    Psk
  • kinekine Member Posts: 12,562
    1) If the Document nO. is PK, why you are not using .GET instead filtering and FIND function?
    2) Use the client monitor to look for mre details. Check that the record in your table is modified only once and on the correct point. If there are other modify actions, look where and check the logic.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • prototyperprototyper Member Posts: 70
    Do you have any code after this that may be causing/issuing an error that forces the db changes to backout ?
    Sleep on it... The best solutions come at 2am
  • pskannaapskannaa Member Posts: 138
    Thanks for Reply foks...

    I hv done, silly mistake while printing i clicked 'YES' then there is no printer here so finally system asking the print save file name THERE IS A MISTAKE i select CANCEL. Now i clicked to SAVE the print file now it's UPDATED.

    Note: mistake was final printing i clicked cancel button b'cz no printer. I use SAVE the print file.
Sign In or Register to comment.