2
Because Enums are type safe (a very good thing), it is difficult to write generic code for any Enum. You can come close by writing methods based on the Names and Ordinals collections but a Caption that differs from the associated Name cannot currently be handled in a non Enum specific way.

It would be really helpful to have an EnumWrapper class that would be of generic type Enum. Then you could set it up and pass it around as an argument instead of needing to write methods that use the Names and Ordinals collection.

Pseudo code: This code could be called for any Enum,
var
MyEnumWrapper: EnumWrapper MyEnum;
MyName: Text;
MyCaption: Text;
begin
for each MyName in MyEnumWarpper.Names do begin
MyCaption := Format(MyName);
if MyCaption <> MyName then begin
Message('Mismatched Name: %1 and Caption: %2', MyName, MyCaption);
end;
end;
end;
Category: Development
STATUS DETAILS
Needs Votes
Ideas Administrator

Thank you for this suggestion! Currently this is not on our roadmap. We are tracking this idea and if it gathers more votes and comments we will consider it in the future.

Best regards,
Business Central Team

Comments

G

This is better pseudo code for an EnumRef that would mimic RecordRef and FieldRef functionality.

var
MyEnumRef: EnumRef;
MyName: Text;
MyCaption: Text;
begin
MyEnumRef := EnumRef.GetEnum(Enum::MyEnum);
for each MyName in MyEnumRef.Names do begin
MyCaption := Format(MyName);
if MyCaption MyName then begin
Message('Mismatched Name: %1 and Caption: %2', MyName, MyCaption);
end;
end;
end;

Category: Development

G

Think of it as an EnumRef in the same manner as RecordRef and FieldRef. You would then have access to all the functionality of any Enum.

EnumRef.GetEnum(MyEnum);

Category: Development