Finance and operations

X++ “Cross reference” for Base Enums

While I love using the cross reference function in Dynamics AX 2012 (and am training myself to use it more often), the cross reference in our environments are often not up to date. Unfortunately this is especially true for our client development environments.

I wrote a job to find all the table fields that is based on a Base Enum. Simply change the enum name in line 5 to the enum you want to investigate, and the job makes a list of table fields that uses the enum. In my case I only needed tables in the ISV and up, but you can tweak it for all layers, or only one.

For example, for InterCompanyOrigin enum, searching through all the fields in the SYS layer:

//Tina van der Vyver
static void enumCrossReference(Args _args)
    EnumName            enumName = enumStr(InterCompanyOrigin);
    EnumId              enumId = enumName2Id(enumName);
    UtilIdElements      utilfield;     
    DictField           dictField;       
    setPrefix(strFmt("Enum: %1", enumName));
    while select parentId, utilLevel, Name, id from utilfield
        where utilfield.recordType == UtilElementType::TableField        
        && utilfield.utilLevel  == UtilEntryLevel::sys
        dictField = new DictField(utilfield.parentId, utilfield.Id);
        if (dictField.baseType() == Types::Enum && dictField.enumId() == enumId)
            info(strFmt("%1: %2 - %3", utilfield.utilLevel, tableId2name(utilfield.parentId),;
InterCompanyOrigin Enum
Output: InterCompanyOrigin Enum

It tends to run quite long, depending on how many fields and layers you include. I’ll see if I can find a way to speed it up in the future.

UPDATE 27 January 2016:
This job does the same for extended data types.

2 thoughts on “X++ “Cross reference” for Base Enums”

Leave a Reply

Your email address will not be published. Required fields are marked *