Method as a parameter (in D365FO)

We usually have methods where the logic is written in code and it just receives some data in parameters. But sometimes it’s benefitial to allow the caller code to define a piece of logic by itself. For example, I can write code to filter a collection and let consumers decide what condition should be used …

Continue reading ‘Method as a parameter (in D365FO)’ »

Dynamic list of methods to execute (in D365FO)

Imagine that you’re running a set of payment matching rules or you’re trying to find discounts based on various criteria. You’ll try one way to find the data, if it doesn’t bring anything, you try another one, and so on. A typical implementation looks like this: found = trySomething();   if (!found) { found = …

Continue reading ‘Dynamic list of methods to execute (in D365FO)’ »

‘is’ and ‘as’ operators with .NET types

I recently ran into an unfortunate limitation of .NET Interop from X++ (in D365FO). I wanted to check if an X++ object is of a given type, nevertheless the type used for the variable declaration was a .NET interface. Here is an example: using Microsoft.Dynamics.ApplicationSuite.FinancialManagement.Currency.Framework;   void demo(IExchangeRateProvider _provider) { if (_provider is ExchangeRateProviderCBOE) {} …

Continue reading ‘‘is’ and ‘as’ operators with .NET types’ »

Exception handling in PU31

In 2018, I wrote the blog post Throwing managed exceptions from X++ in D365FO, where I pondered upon how throwing proper exceptions objects in X++ would be beneficial. This is still true. I also showed a proof of concept how it can be done despite the fact that X++ doesn’t directly support it. But this …

Continue reading ‘Exception handling in PU31’ »

Calling async method from X++

There is a trend in the .NET world to make time-consuming calls asynchronous, to prevent applications from getting blocked when waiting for a response from a web service and things like that. Many existing APIs were enhanced with asynchronous variants of previously synchronous actions and some newer APIs offer only asynchronous methods. So… how can …

Continue reading ‘Calling async method from X++’ »