I am trying to catch an exception in custom code I wrote in extension class of SalesPackingSlipJournalPost.endPost(), I am calling base endPost method first using CoC and trying to generate a custom report at the end of the posting , the issue is that if an error/exception occur in generating/printing of custom report the packing slip posting fails which I don't want to happen, The packing slip posting should not fail if for some reason there is an error/exception in printing custom SSRS report. In this situation I want to catch the exception and display an infolog saying the packing slip is posted but the generation/printing of custom report failed due to xyz reason.
my code look something like this.
public void endPost()
{
next endPost()
try
{
//My code that involve writing to some tables and calling controller class of a SSRS report; some times i get an exception in
meunFunciton.run(args) in one of my custom methods.
}
catch
{
//Display Infolog about error
}
}
I am not able to achieve my desired outcome, when the exception occurs system display it in UI and the posting of packing slip is cancelled.
I moved my code to Post event hander of Run method of SalesFormLetter and it worked. the packing slip posted even if there is an error/exception in the generation/printing of SSRS report.
for some weird reason my question is appearing under some other profile so can't mark your answer as verified answer. but thanks again
Martin Dráb230,370Most Valuable Professional
on at
It's an inherent design of X++. Assuming by the name of the method, it's inside a transaction.
When an exception occurs within a transaction scope (TTSBEGIN, TTSCOMMIT), it aborts the transaction, and except for a few cases, no try/catch statement inside a transaction scope can process an exception.
Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.