AX / D365FO – How to get a Base enum integer internal value with a SQL Server query or a Job

Are you like me going crazy to figure out how to find the integer value of an enum type? No problem, the solution is around the corner.

In this case you have 2 options :

  • Open SSMS SQL session and run a query.
  • Create a job / Runnable class

SQL Query

select t1.NAME,t2.ENUMID,t2.ENUMVALUE,t2.NAME EnumValueName 
from ENUMIDTABLE t1
inner join ENUMVALUETABLE t2 on t1.ID=t2.ENUMID
where t1.NAME='SalesType'   //Put here your Base Enum Type Name

Job / Runnable class

    static void main(Args _args)
    {
        DictEnum enum = new DictEnum(enumName2Id("DEDCoreProductCatalogSetupRecType"));
        int i;
        for (i=0; i < enum.values(); i++)
        {
            info('enum integer value : '+  int2Str(enum.index2Value(i)) + ' - enum name : '+ enum.index2Label(i));
        }
    }

One response to “AX / D365FO – How to get a Base enum integer internal value with a SQL Server query or a Job”

  1. Hugo Alves Avatar
    Hugo Alves

    Hi Marco,
    good to know that this EnumIdTable exists in the SQL side only, thanks for sharing.

    I had a similar Job but i wanted to get rid of this hardcoded choice, so that it can be useful tool to look at any Enum, so i just made a small improvement to this job…

    By prompting the extendedTypeStr(EnumName) it allows user to select an existing Enum from the AOT List to view its structure.

    Like

Leave a comment