[solved] Sales Header does not exist after deleting Invoice

DenSterDenSter Member Posts: 8,305
So I have Sales Invoice number 123, which I want to delete. I get the first message 'there will be a gap in the numbering series', I click Yes I want to proceed. Then the next message 'do you want to print' I click no I don't want to print. When it gives me back the form it gives me an error message "Sales Header does not exist. Type=Invoice No.=123", which is the number that I just deleted.

Anybody have a good tip on how to get rid of that message?

Comments

  • SavatageSavatage Member Posts: 7,142
    did you filter on that Invoice or did you Ctrl-F?
  • DenSterDenSter Member Posts: 8,305
    No filters, no Ctrl+F. From the (unposted) Sales Invoice form hit F4 to delete the invoice. It'll ask 'do you want to delete?' you click yes, and by the time it gives control back to the form you get the error message.

    It seems to be related to having the same numbering series for invoices and posted invoices. With the DELETE and COMMIT in place, and setting up a different numbering series for posted invoices also makes the error go away, but then again, it doesn't go into printing the empty invoice either.

    Additional information: At some point in the OnDelete of the Sales Header table, it does DELETE and COMMIT, right before it tries to print the 'empty invoice'. Commenting out those two lines seems to fix the problem (i.e. not getting the error again), but surely that code is there for a reason.
  • SavatageSavatage Member Posts: 7,142
    Ah - i though you werwe talking "posted"

    We never used the sames # series for order/invoice/credit and posted order/invoice/credit perhaps that's why we've never seen that message.
  • munib00munib00 Member Posts: 29
    You are right there. I only noticed this just 2 months ago. Where the Invoice and Posted Invoice had the same number series.
    I did the same too in commenting out the piece of code.
  • DenSterDenSter Member Posts: 8,305
    The only thing that can go wrong with that solution is that theoretically, you can print the sales invoice, have an error after that, NAV rolls back the deletion, and now you have a printed invoice for an invoice that doesn't exist in NAV. I'm lucky in that my customer doesn't need to ever print these, so I commented out the whole section where it tries to print the document.
Sign In or Register to comment.