1

Variants currently have a function corresponding to most datatypes, such as IsAction, IsCode, IsCodeunit, IsGuid.

There are a LOT of variations of this, and the list grows with every introduced datatype (e.g. IsTextBuilder introduced last year).


If a function uses a case statement to handle a variant, this will currently be managed something like


case true of

myVariant.IsXmlNode(), myVariant.IsXmlElement():

// Handle XML content

;

myVariant.IsJsonToken(), myVariant.IsJsonObject():

// Handle JSON content

;

end;


This is cumbersome. I propose the introduction of Type and SubType which can be used to determine and handle specific typing cases, especially for complex datatypes such as Record, Codeunit, Page, or Enum (currently handled by the inconvenient IsOption function on variants).


The introduction of GetType and GetSubType functions along with a system type "DataType" that holds the generic datatypes could be utilised in such a fashion:


case myVariant.Type() of

DataType::Record:

if myVariant.GetSubType() = Database::"My Table" then

// Handle My Table variable

;

DataType::Enum:

if myVariant.GetSubType() = Enum::"Sales Line Type" then

// Handle Sales Line Type variable

;

end;


This would make developing abstract functions more manageable and would bring the AL language in line with other programming languages.

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