Al: InitValue for enums no longer working

Created on 26 Aug 2020  Â·  4Comments  Â·  Source: microsoft/AL

Describe the bug
A table field of type enum cannot have an InitialValue

To Reproduce

Given: enum with some members. a table with a field referencing the enum.
Add property InitValue to the table field

AL Code to reproduce the issue

image

Expected behavior

Works like it did since resolution of #4192

Screenshots

5. Versions:

  • AL Language: v6.0.321546
  • Business Central: Platform 17.0.15765.0 + Application 17.0.15854.0
bug intellisense

Most helpful comment

Thanks @RafaelKoch, You found the issue.
When the value is a keyword then it can't be used without quotes and unfortunately we have a bug where intellisense doesn't add them.
I'll mark it as a bug

enum 50100 MyEnum
{
    value(3; Warning) { }
    value(4; if) { }
}

table 50100 MyTable
{
    fields
    {
        field(2; EnumField; Enum MyEnum)
        {
            InitValue = ^;
        }
    }
}

All 4 comments

While you are at it, can you please also add intellisense for choosing all available Enum values?
image
(The screenshot is from AL Language 5.0.320540, where the assignment still works.)

Hi @RafaelKoch,
Can you provide a complete simple example since I am not able to reproduce the issue.
Thanks.

However I was able to reproduce the issue @NKarolak highlights and can confirm that is solved in a future release.

Hi @thpeder ,

we found the way to make it work, and accidentally maybe also the reason You could not repro: The enum value is called Warning and the InitValue was assigned like this: InitValue = Warning. This solution used to compile just fine in v15 and v16.

Now somehow the value has to be set that way InitValue = "Warning"

So most likely the word Warningis ambiguous now. So forget about this aspect, but check if Intellisense will put it in correctly :-)

Thanks @RafaelKoch, You found the issue.
When the value is a keyword then it can't be used without quotes and unfortunately we have a bug where intellisense doesn't add them.
I'll mark it as a bug

enum 50100 MyEnum
{
    value(3; Warning) { }
    value(4; if) { }
}

table 50100 MyTable
{
    fields
    {
        field(2; EnumField; Enum MyEnum)
        {
            InitValue = ^;
        }
    }
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

TinaMenezes picture TinaMenezes  Â·  3Comments

malue19 picture malue19  Â·  3Comments

worldofthenavcraft picture worldofthenavcraft  Â·  3Comments

ThomasBrodkorb picture ThomasBrodkorb  Â·  3Comments

kine picture kine  Â·  3Comments