String format options for utcDateTime

I’ve run into a problem that reminded me that while X++ types and corresponding CLR types (such as str and System.String) can often be user interchangeably, they aren’t the same. I was trying to convert a utcdatetime value to the standard “sortable” format in D365FO, for which I wrote the following code: utcdatetime currentDateTime = …

Continue reading ‘String format options for utcDateTime’ »

Throwing managed exceptions from X++ in D365FO

Update! PU31 has added the ability to throw managed exceptions. Read more about it here. What I really miss in X++ is the ability to throw exception objects. If you throw an exception in X++, it’s just a number defining what kind of exception it is, which usually says just “Error” (Exception::Error). You also typically …

Continue reading ‘Throwing managed exceptions from X++ in D365FO’ »

Catching exceptions in AX 7

In this blog post, I briefly recapitulate how to throw and catch exceptions in X++ and introduce a new way of handling CLR exceptions in AX 7. X++ exceptions When you want to throw an exception in X++, you typically do it by something like this: throw error("It’s broken!"); It’s a functional equivalent of adding a …

Continue reading ‘Catching exceptions in AX 7’ »

Generic types in X++ (AX 7)

This blog post assumes that you’re familiar with generic types. If it’s not the case, I suggest you look at my previous blog post before continuing. You can’t create generic types and methods in X++, so why would you care about generics at all? The main reason is that it’s used heavily in .NET codebase …

Continue reading ‘Generic types in X++ (AX 7)’ »

Getting record from QueryRun in C#

This week I wrote some C# code using .NET Interop to X++ and I needed to get records from a QueryRun object. You surely know how to do it in AX (by calling QueryRun.get()), nevertheless I wanted to do it in a slightly better way. My method is rather short, but it may be difficult …

Continue reading ‘Getting record from QueryRun in C#’ »