Hi, an external system is writing in a customized table in dynamics NAV (2018) (called interface table) which I process and then write an item-journal line and then post it.
I am validating the value of the fields in that interface table using try functions and in case of error I mark the record as error so the external system can retrieve it and eventually correct the error shown (for instance: Item code field is empty). This all works fine, but the problem comes when I try to post the line. I have found no way of catching eventual posting errors in order avoid an standard error message for posting (for instance: Not enough stock of product xxxx)
How can I catch the error before it raises? Try function wont work since the procedure writes into the database. "IF codeunit.run Item Jnl.-Post Line" is not allowed for similar reasons...
I have check the preview posting for sales header, but it is kind of tricky since the preview flag is all around codeunit 80 and this is not happening with 22 Item Jnl.-Post Line where I need it.
Any ideas?
*This post is locked for comments