More AX SSRS Screencasts and Instructions on Getting an AX Enum into a Report


We are up to 25 screencasts as of last night. You can find the full list here:

In particular I want to call attention to Screencast 25: Getting the Values of an AX Enum into a Report

I’ve pasted the code used to retrieve the Enum data into a DataTable

public static System.Data.DataTable GetAXEnum(string enumname)
    if (enumname == null)
        throw new System.ArgumentNullException("enumname");
    var dt = new System.Data.DataTable();
    dt.Columns.Add("Symbol", typeof(string));

    var ax = Microsoft.Dynamics.Framework.Reports.SessionManager.GetSession();
    int enum_id = (int)ax.CallStaticClassMethod("Global", "enumName2Id", enumname);
    var enum_obj = ax.CreateAxaptaObject("DictEnum", Convert.ToString(enum_id));
    int val_count = (int)enum_obj.Call("values");


    for (int i = 0; i < val_count; i++)
        string symbol = (string)enum_obj.Call("value2Symbol", i);

        if (symbol.Length > 0)
            int int_value = (int)enum_obj.Call("symbol2Value", symbol);
            string label = (string)enum_obj.Call("value2Label", i);
            dt.Rows.Add(symbol, int_value, label);
    return dt;

Comments (4)

  1. shiwa says:

    in here what is you class declaration?

  2. micah says:

    I am creating a report in SSRS.  When I pull in values from the database they come in as Enums.  Is there a way to assign values for these Enums?  For example,

    0 = blank

    1 = Labor

    2 = Parts

    Thanks in advance,

  3. Peter Kranenburg says:

    Great post! I was looking for how to retrieve an Ax-table into SSRS by using a data method and a static Ax class method. Unfortunately it's not possible to directly assign the output of a static class return type table into a C# datatable (dt) type.

  4. Peter says:

    This is an example for a number of enum values (val_count) that are iterated in the for clause. Do you perhaps have an example for putting an Ax-table (as a result of an static Ax-class method) into dt.Rows.Add?

    Thanks in advance.

Skip to main content