Search This Blog

Wednesday, January 25, 2012

To create XML files of developer documentation for the whole application


  1. Create a folder in which you will create the XML documentation files. This procedure will reference a folder that has the path, C:\XMLDoc.
  2. Open the command prompt.
  3. Type the following to create a documentation file for the whole application. Ax32.exe -startupcmd=xmldocumentation_C:\XMLDoc\documentation.xml
  4. Type the following to create a reflection file for the whole application. Ax32.exe -startupcmd=xmlreflection_C:\XMLDoc\reflection.xml

Ax2012 Power shell scripts for SSRS usage

Power shell script for reports in AX2012
we can use power shell scripts to deploy the reports to server
Open the administrative tools->Right click on MS Dynamics AX 2012 management shell and select run as admin.
Now it will opens the Powershell script to run the commands.
I will provide some sample scripts for SSRS

To get the List of reports, It will load all the reports into the reports label.
$reports=get-AXReport -ReportName *

To view the reports list
$reports

To Filter the reports list we can write the query on the object as following.
$reports | select-object name | where {$_.name -like "inventTrans*"}

To publish the reports,
publish-AXReport -reportname InventTransList
If we want to publish multiple reports just add another report after that with the seperator ,

To publish all the reports which skips admin check
publish-AXReport -reportName * -skipreportserveradminCheck


Wednesday, January 18, 2012

Imports data from Excel in AX2012 using X++ programming


Import Exchange Rates from Excel in AX2012 using X++

Following job is used to import the Exchange rates into the  ExchangeRate Table using ExchangeRateCurrencyPair for default currency type

Input-Excel file Name,ExcelSheetName


static void krishh_readExchangeRatesExcel(Args _args)
{
    SysExcelApplication application;
    SysExcelWorkbooks workbooks;
    SysExcelWorkbook workbook;
    SysExcelWorksheets worksheets;
    SysExcelWorksheet worksheet;
    SysExcelCells cells;
    COMVariantType type;
    int row;

    // Currency code variables for loading into exchange Rates.
    CurrencyCode  _fromCurrencyCode;
    CurrencyCode  _toCurrencyCode=CompanyInfo::standardCurrency();
    TransDate     _exchangeRateDate;
    CurrencyExchangeRate _exchangeRate;
    ExchangeRateTypeRecId   _exchangeRateTypeRecId
    ;

    application = SysExcelApplication::construct();
    workbooks = application.workbooks();

    // gets the default ExchangeType RecId
    _exchangeRateTypeRecId=ExchangeRateType::findByName('default').RecId;
    try
    {
        workbooks.open(filename);
    }
    catch (Exception::Error)
    {
        throw error("File not found");
    }
    workbook = workbooks.item(1);
    worksheets = workbook.worksheets();
    worksheet = worksheets.itemFromName(sheetName);
    cells = worksheet.cells();

    //Iterate through cells and get the values
    do
    {
    //Incrementing the row line to next Row
    row++;
    _fromCurrencyCode = cells.item(row, 1).value().bStr();
    _exchangeRateDate = cells.item(row,2).value().date();
    _exchangeRate     = cells.item(row,3).value().double();

    //Imports the Exchange Rates
    ExchangeRate::importExchangeRate(_fromCurrencyCode,_toCurrencyCode,_exchangeRateTypeRecId,_exchangeRateDate,_exchangeRate,true,false);

    // Loads the next row into the variant type and validating that its is empty or not
    type = cells.item(row+1, 1).value().variantType();
    }
    while (type != COMVariantType::VT_EMPTY);

    // quits the application
    application.quit();

}