Hello.
In my development (I use Dynamics 365 BC Saas), I need to post sales documents, purchase, journal lines, transfer orders, etc and be able to capture the errors that occur during posting. If I call the posting codeunits as follows:
ok := PurchPost.Run(PurchaseHeader);
I get the following error: "An error occurred and the transaction is stopped".
From a one page action I call a custom codeunit that does a series of checks and updates and finally calls the posting codeunit.
Why does this error occur? Would there be any way to check if an error has occurred during registration?
I tried to use [TryFunction], but it doesn’t work very well, because if one line of the order gives error but the rest are correct, it registers all lines except the one that gives error.
Regards
Eva