Empty/None/Null on Value Implementation for Enum with Interface

Hello all,

I am wondering if there is a way to specify an "Empty", "None", "Null" or "Nil" (any really) implementation for Enum values that do not/should not implement an interface.

for example, assuming I have the following enum:

enum 50000 "Colors" implements IColor
{
    value(0; "None") { }
    Value(1; "Red")
    {
        Implementation = IColor = ColorRedCodeunit;
    }
    Value(1; "Green")
    {
        Implementation = IColor = ColorGreenCodeunit;
    }
    Value(1; "Blue")
    {
        Implementation = IColor = ColorBlueCodeunit;
    }
}

The first value "None" should not implement any interface (i.e. no color is selected). The problem is since the Enum implements an interface, the "Implementation" needs to be declared on the Enum Value. I understand I can assign a DefaultImplementation on the Enum level but that does not solve the problem since no logic should be implemented on the first Value "None". I tried to used

  • DefaultImplementation = IColor = "None";
  • DefaultImplementation = IColor = "Empty";
  • DefaultImplementation = IColor = "Null";

But none of them worked.

I can, of course, go around this issue by creating an empty Codeunit that implements the same interface with no logic at all and assign it to those value that do not implement any logic, but this does not seem like the right way to go. Instead, there should be some sort of "None", "Empty", "Not Declared" or some other way to indicate no implementation should be associated with a specific enum value.

I am just hoping someone has already been through this and found a solution to this problem.

Regards,

Related
Recommended