How to skip next in CoC of a method in X++


Hey guys! Did you know that there is a hack how to skip next in an extended X++ method, wrapped using CoC (Chain of Command), which is NOT decorated with the Replaceable attribute?
This hack also works inside a transaction (ttsLevel > 0) 😀

WARNING: Please note, we DO NOT RECOMMEND using this hack! Microsoft can change behaviour of next, exception handling, etc. in the future and this "technique" might stop working.

Anyway, sometimes you simply can't find another way around 😊

Let's take a look at the following extension of the built-in class SrsPrintDestinationTokensNone and its method expandEmailToken().

Initially, we used throw Exception::Error but this solution didn't work inside a transaction (ttsLevel > 0).

Learn more on CoC in MS doc >>
Learn more on exception handling inside a transaction >>

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Docentric respects your privacy. Learn how your comment data is processed >>

Docentric respects your privacy. Learn how your comment data is processed >>