Extract List of Classes and Class's Properties

Hi All,

Is it possible to get all the classes listing and the class's properties in AOT to extract into Excel?

For example:

Refer to below, I would like to extract in Excel. Can or not?

  • Hi Aiman,

    Try the below Code in your Jobs

    // AX 2009

    static void Export_Classes_propertied(Args _args)
    {
        SysExcelApplication xlsApplication;
        SysExcelWorkBooks xlsWorkBookCollection;
        SysExcelWorkBook xlsWorkBook;
        SysExcelWorkSheets xlsWorkSheetCollection;
        SysExcelWorkSheet xlsWorkSheet;
        SysExcelRange xlsRange;

        int row = 1;
        str fileName;

        TreeNode classesNode = TreeNode::findNode(@'\Classes');
        TreeNodeIterator iterator = ClassesNode.AOTiterator();
        TreeNode classNode = iterator.next();
        ClassName   className;
        UtilElements utilElements;

        System.DateTime CreatedSysDate, ModifiedDate;
        utcdatetime UtcCreatedDate, UtcModifiedDate;
        str StrCreatedDate, strModifiedDate;
        ;

        //Filename
        fileName = "C:\\Users\\saadullah\\Desktop\\Class.xlsx";  // Define your Excel Path

     


        //Initialize Excel instance
        xlsApplication = SysExcelApplication::construct();

        //Open Excel document
        //xlsApplication.visible(true);

        //Create Excel WorkBook and WorkSheet
        xlsWorkBookCollection = xlsApplication.workbooks();
        xlsWorkBook = xlsWorkBookCollection.add();
        xlsWorkSheetCollection = xlsWorkBook.worksheets();
        xlsWorkSheet = xlsWorkSheetCollection.itemFromNum(1);


        //Excel columns captions
        xlsWorkSheet.cells().item(row,1).value("ID");
        xlsWorkSheet.cells().item(row,2).value("Name");
        xlsWorkSheet.cells().item(row,3).value("Extends");
        xlsWorkSheet.cells().item(row,4).value("RunOn");
        xlsWorkSheet.cells().item(row,5).value("CreatedBy");
        xlsWorkSheet.cells().item(row,6).value("CreatedDateTime");
        xlsWorkSheet.cells().item(row,7).value("ChangedBy");
        xlsWorkSheet.cells().item(row,8).value("ChangedDateTime");
       

        row++;


        while (classNode)
        {
            className = classNode.treeNodeName();
            classNode.AOTgetProperties(true);

            select utilElements
                where utilElements.RecordType == UtilElementType::Class
                && utilElements.Name == className;

            UtcCreatedDate = utilElements.createdDateTime;
            CreatedSysDate = Global::utcDateTime2SystemDateTime(UtcCreatedDate);
            UtcCreatedDate = Global::CLRSystemDateTime2UtcDateTime(CreatedSysDate);

            StrCreatedDate = DateTimeUtil::toStr(UtcCreatedDate);

            UtcModifiedDate = utilElements.modifiedDateTime;
            ModifiedDate = Global::utcDateTime2SystemDateTime(UtcModifiedDate);
            UtcModifiedDate = Global::CLRSystemDateTime2UtcDateTime(ModifiedDate);

            strModifiedDate = DateTimeUtil::toStr(UtcCreatedDate);


            xlsWorkSheet.cells().item(row,1).value(classNode.applObjectId());
            xlsWorkSheet.cells().item(row,2).value(classNode.AOTgetProperty('Name'));
            xlsWorkSheet.cells().item(row,3).value(classNode.AOTgetProperty('Extends'));
            xlsWorkSheet.cells().item(row,4).value(classNode.AOTgetProperty('RunOn'));
            xlsWorkSheet.cells().item(row,5).value(utilElements.createdBy);
            xlsWorkSheet.cells().item(row,6).value(StrCreatedDate);
            xlsWorkSheet.cells().item(row,7).value(utilElements.modifiedBy);
            xlsWorkSheet.cells().item(row,8).value(strModifiedDate);
            classNode = iterator.next();
           
            row++;

        }


        //Check whether the document already exists
        if(WinApi::fileExists(fileName))
        WinApi::deleteFile(fileName);


        //Save Excel document

        xlsWorkbook.saveAs(fileName);
        xlsWorkbook.comObject().save();

        //Open Excel document
        xlsApplication.visible(true);


        //Close Excel
        //xlsApplication.quit();
        //xlsApplication.finalize();

    }

     

     

Related
Recommended