Wednesday, November 22, 2017

AX - How get enum labels to db table

When you have AX enum, often you need to read its labels externally - for example in SQL question.

In AX exists table SRSAnalysisEnums, which contain enum name, enum value and its label.
select * from SRSAnalysisEnums
where
enumname = 'NoYes' and
languageid in ( 'de', 'en-us' )
Output:
ENUMITEMVALUE ENUMITEMLABEL LANGUAGEID ENUMNAME ENUMITEMNAME RECVERSION RECID

0 Nein de NoYes No 1 5637179205
0 No en-us NoYes No 1 5637144576 1
Ja de NoYes Yes 1 5637179250 1 
Yes en-us NoYes Yes 1 5637144577
For rebuild this table (->new enum in AX) you can use class BIGenerator, method populateSRSAnalysisEnums(). Implicitly are generated enums from tables in AX BI perspectives.
static void cieb_updateSSRSEnums(Args _args)
{
    BIGenerator::populateSRSAnalysisEnums();
    info( "OK" );
}
Explicitly you can change in inner method addFrameworkEnumsToDictEnumSet(), where you can define some others special enums for SRSAnalysisEnums table:
void addFrameworkEnumsToDictEnumSet()
{
    addEnumToDictEnumSet(new DictEnum(enumNum(boolean)));
    addEnumToDictEnumSet(new DictEnum(enumNum(NoYes)));
    addEnumToDictEnumSet(new DictEnum(enumNum(AutoNoYes)));

    /* -- added - start */
    addEnumToDictEnumSet( new DictEnum( enumNum( cieb_technology_sale_type_enum ) ) );
    addEnumToDictEnumSet( new DictEnum( enumNum( cieb_technology_type_enum ) ) );
    addEnumToDictEnumSet( new DictEnum( enumNum( cieb_technology_type1_enum ) ) );
    /* -- added - end */

    addEdtEnumToDictEnumSet(new DictType(extendedTypeNum(BIIsNotApplicable)));
}

No comments:

Post a Comment