Enum issue
Hello, We have 3 extensions
- Base – Contains “Base Enum”;
enum 50100 "Base Enum" { Extensible = true; value(0; None) { Caption = ' '; } value(1; One) { Caption = 'One'; } value(2; Two) { Caption = 'Two'; } } - Ext1 – Contains “Ext1 Enum”, that extends “Base Enum”;
enumextension 50150 "Ext1 Base Enum" extends "Base Enum" { value(3; Three) { Caption = 'Tree'; } } - Ext2 – Contains “Ext2 Enum”, that extends “Base Enum”;
enumextension 50100 "Ext2 Base Enum" extends "Base Enum" { value(4; Four) { Caption = 'Four'; } value(5; Five) { Caption = 'Five'; } }
Publishing and installation: Step 1 – publishing Base; Step 2 – publishing Ext2 with dependency on Base; Step 3 – publishing Ext1 with dependency on Base;
If we use "id": "86efc993-7f41-48fb-9918-f689c52c8619" for Ext2 then:
Step 1 Result
Step 2 Result
Step 3 Result
Enum values were corrupted (numbers don’t match values):
Id = 3 – Name = Four
Id = 4 – Name = Five
Id = 5 – Name = Three
If “id” for Ext2 is changed(for example: "c52b2524-0a71-440d-9303-f632428e6455") then:
Step 1 Result
Step 2 Result
Step 3 Result
Same behavior if extend enum from C/AL object.
Somehow ids specified in app.json cause unpredictable behavior of enums. Can you please investigate this issue?
Example.zip
Seems related to the AL language. Transferring issue to AL repo.
It is deterministic and the AppId is involved. We are considering to add a way of arranging enum-values in the future, but we don't have a timeline for that.
How about arranging values... by their value? What's the point of assigning values to Enums if BC isn't going to respect that order? There should be no other variables involved.
I've come across this issue and the order of the values seems to be determined by the timestamp associated with AppID, i.e., newer extensions will show up before older ones.
This seems like a huge oversight and should be fixed ASAP because it most certainly leads to data corruption and makes the Enum functionality totally counterproductive.
The ordinal value assigned to the individual enum values are used for persistence. That AppId have no influence on the persisted values. This will not lead to data corruption.
The Order in the UI is not related to the persisted values.
Extensions gets their values appended to the original values. And yes currently the AppId dictates that order.
We have on backlog to support re-ordering of enum values in the UI, but we don't have an ETA for that.
But that's the thing: the problem is not the order in the UI, the values themselves get corrupted so there's definitely data corruption.
Somehow the numbers assigned to the values do not mirror the values attributed to the options.
In any case, there's absolutely no reason for Enums not to respect the order of the values, especially since they were introduced to replace Option strings, which did worked like this.
The UI is not ordered by the enum value ordinals. The ordinal values used in enum extensions are supposed to be in the partner range to avoid collisions. The enum values are used for persistence, not for any ordering in the UI.
Again, i'm not talking about the order in the UI. I'm talking about data corruption when new Enum options are added, because that certainly happens.
Please provide a repro.
Linking related issues: Extended Enum caption order is different to the Enum value when used as an option field. #5651 Enums are being evaluated by element position, not by its value #5646
Hi! Thank you for taking the time to share this request — we appreciate the thoughtful feedback and understand how important extensibility is for partners building on Business Central.
This repository is focused on issues related to the AL compiler and developer tools. Extensibility requests like this — which require changes to the base application or platform — are best tracked through https://github.com/Microsoft/ALAppExtensions or our Ideas forum at https://aka.ms/BCIdeas.
We encourage you to post your request there (or vote it up if it already exists) so it gets the visibility it deserves. We actively monitor top ideas and consider them for future releases.
Thank you for helping shape the future of Business Central!