Missing values: getting the System.Missing.Value value

When dealing with office integration scenarios and when calling APIs that are based on old COM interfaces, there  is a need to specify that a value is not provided. The notmal way to do this (say, in C#) is to use


Now, as it happens, Value is not a static property, as one might expect, but instead a public static field. It is currently not possible in X++ to reference the value of a field.

There are at least two ways to solve the problem:

  1. You can use a managed method to get the value. This has the disadvantage that you need to put this glue code in an assembly that is deployed to your Ax installation. This may or may not be a problem, depending on your situation, but it is not exactly elegant.

  2. Or, you can use reflection from X++ to get the value, as shown here:
   System.Type type = System.Type::GetType(“System.Reflection.Missing”);
   System.Reflection.FieldInfo info = type.GetField(“Value”);
   System.Object value = info.GetValue(null);

This has a performance penalty involved, but that can rpobably be ignored in most cases.