Guaranteed run of code when record is inserted (invoice is posted)

I'm working on a legacy system (Nav 4.03). When sales invoices are posted, I need to make sure that certain code runs, regardless of what exactly triggers the posting of the invoice. I used to be able to handle this, having a place in the posting routine that would surely ALWAYS run during the posting of an invoice. But as the system is extremely modified (even with it's on set of sales invoice header / lines tables), and ... apparently various ways to drive the posting of an invoice, my code doesn't always run. (I need to run it, to check if I can close "sales contracts" which is another modification.

As I say: I have been trying to put my code into the posting routine -> it sometimes runs, but not always
I have tried to put it into the "on insert" trigger in the sales invoice header, but that trigger apparently isn't used (as the insert command isn't followed with (true).


  • kylehardinkylehardin Member Posts: 257
    I think the better solution would be to figure out the steps that cause the code to not run, and solve that problem, rather than trying to code around the problem. Something is wrong with codeunit 80, or more likely the code that calls the posting code. Maybe some combination of the invoice and ship booleans. Code coverage might be helpful.
    Kyle Hardin - ArcherPoint
Sign In or Register to comment.