Tuesday, October 20, 2015

Get list of object AX2012

This is the jobto save it in excel:

static void Job40(Args _args)
{
    UtilElements    UtilElementsLocal;
    SysExcelApplication application;
    SysExcelWorkbooks workbooks;
    SysExcelWorkbook workbook;
    SysExcelWorksheets worksheets;
    SysExcelWorksheet worksheet;
    SysExcelCells cells;
    SysExcelCell cell;
    int row;
    ;

    application = SysExcelApplication::construct();
    workbooks = application.workbooks();
    workbook = workbooks.add();
    worksheets = workbook.worksheets();
    worksheet = worksheets.itemFromNum(1);
    cells = worksheet.cells();
    cells.range('A:A').numberFormat('@');

    cell = cells.item(1,1);
    cell.value("Object");
    row = 1;
    while select * from UtilElementsLocal
        where UtilElementsLocal.recordType == UtilElementType::WebControl
        && UtilElementsLocal.utilLevel == UtilEntryLevel::usr//global::currentAOLayer()
    {
        row++;
        cell = cells.item(row, 1);
        cell.value(UtilElementsLocal.name);
    }

    application.visible(true);
}

You can change the type of object you want and also from which layer you want in UtilElementType & UtilEntryLevel respectively.

Another way is to use Shell command:
Type C:\>(Get-AXModel -Model “USR Model” -Details).Elements | Out- File <File path>