Business Central 2023 wave 2 (BC23): Check if a field is an enum (New FieldRef.IsEnum method)

Dynamics 365 Business Central

Hi, Readers.
The public preview for Dynamics 365 Business Central 2023 release wave 2 (BC23) is available. Learn more: Link.

I will continue to test and share some new features that I hope will be helpful.

In this post, I would like to talk about how to check if a field is an enum. This is not yet documented in the Business Central 2023 release wave 2 (BC23) release plan. But it is mentioned in AL Language extension changelog Version 12.0

Let me give a simple example.
FieldRef Data Type: Identifies a field in a table and gives you access to this field.

procedure IsEnum(): Boolean
Checks if the currently selected field is an enum.

Source code:

pageextension 50100 CustomerCardExt extends "Customer Card"
{
    trigger OnOpenPage()
    var
        RecRef: RecordRef;
        FldRef: FieldRef;
        Msg: Label 'Field ''%1'' is an enum';
    begin
        RecRef.Open(Database::Customer);
        FldRef := RecRef.Field(39);
        if FldRef.IsEnum then
            Message(Msg, FldRef.Name);
    end;
}

Very simple, give it a try!!!😁

PS:
1. In BC22.5 (runtime 11.0)

2. How to check whether a field is a Flowfield via AL (Check the class of the field)

END

Hope this will help.

Thanks for reading.

ZHU

コメント

Copied title and URL