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));
        }
    }

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s