20

Hi,


There should be a way to rename enum values (and maybe fields or other things) without using obsoletion flow and creating new enum value and upgrade codeunit.


Add a new property Aliases to enum value. Aliases would be names of enum value that were used in the past.

The compiler must check that enum value name is not an enum value alias - this idea is only for renaming enum value names.


For example if I have enum value like this:

value(123; SomeVal)
{
Caption = 'SomeVal';
}

And I want to rename it to "Some Value" to make code more readable (example syntax).

value(123; "Some Value")
{
Caption = 'SomeVal';
Aliases =
[SomeVal, ObsoleteTag = '21.0'],
["Some_Val", ObsoleteTag = '19.0']; // suppose that the rename happened multiple times
}


Using SomeVal or Some_Val should show obsolete warning - the goal is to only obsolete the name.


This could be useful in Base Application too - in BC22 a lot of "Report Selection Usage" enum values got new captions, but value names remains unreadable.

value(22; "M1") { Caption = 'Job Card'; }
value(23; "M2") { Caption = 'Mat. & Requisition'; }
value(24; "M3") { Caption = 'Shortage List'; }
value(25; "M4") { Caption = 'Gantt Chart'; }

IMHO these should be handled by obsoleting old value and creating new value. But with this idea implemented you could write:

value(22; "Job Card") { Caption = 'Job Card'; Aliases = [M1, ObsoleteTag = '22.0']; }
value(23; "Mat. & Requisition") { Caption = 'Mat. & Requisition'; Aliases = [M2, ObsoleteTag = '22.0']; }
value(24; "Shortage List") { Caption = 'Shortage List'; Aliases = [M3, ObsoleteTag = '22.0']; }
value(25; "Gantt Chart") { Caption = 'Gantt Chart'; Aliases = [M4, ObsoleteTag = '22.0']; }


I think this idea could be extended to other things with names like table and page fields.


Implementing this idea would add a lot of complexity to the compiler and analyzers, but it would also enable less "painful" obsoletion process when only the name changes, but not the functionality.


One case where this rename obsoletion would be extremely useful is when you shorted enum name (there was a time when enum name length was unrestricted): now this requires obsoleting enum, obsoleting table field that uses the enum, obsoleting page field, creating new enum with shorter name, creating table field that uses new enum, creating page field, many many changes in code to handle cases if dependent app still uses the old table field. With this idea you would only need to rename the enum and add aliases so the existing code wouldn't break.


Thanks.

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