Alfasith AX

Alfasith AX
اللَّهُمَّ انْفَعْنِي بِمَا عَلَّمْتَنِي، وَعَلِّمْنِي مَا يَنْفَعُنِي، وَزِدْنِي عِلْمًا

Sunday, December 14, 2014

Code to refresh AOT in AX

Hi,

public server static void refreshServer()
{
    #AOT ;
    TreeNode::findNode(#TablesPath).AOTrefresh();
    TreeNode::findNode(#TableMapsPath).AOTrefresh();
    TreeNode::findNode(#ViewsPath).AOTrefresh();
    TreeNode::findNode(#ExtendedDataTypesPath).AOTrefresh();
    TreeNode::findNode(#BaseEnumsPath).AOTrefresh();
    TreeNode::findNode(#LicenseCodesPath).AOTrefresh();
    TreeNode::findNode(#ConfigurationKeysPath).AOTrefresh();
    TreeNode::findNode(#SecurityKeysPath).AOTrefresh();
    TreeNode::findNode(#TableCollectionsPath).AOTrefresh();
    TreeNode::findNode(#PerspectivesPath).AOTrefresh();
    TreeNode::findNode(#MacrosPath).AOTrefresh();
    TreeNode::findNode(#ClassesPath).AOTrefresh();
    TreeNode::findNode(#ReportsPath).AOTrefresh();
    TreeNode::findNode(#ReportTemplatesPath).AOTrefresh();
    TreeNode::findNode(#SectionTemplatesPath).AOTrefresh();
    TreeNode::findNode(#QueriesPath).AOTrefresh();
    TreeNode::findNode(#JobsPath).AOTrefresh();
    Dictionary::aodFlush();
    Dictionary::dataFlush();
    flush UtilElements, UtilIdElements;
}

Regards,

Monday, December 1, 2014

An unexpected error has occurred while opening the workflow. See the event log on the AOS and contact your system administrator to resolve the issue.

Hi,

Error : "An unexpected error has occurred while opening the workflow. See the event log on the AOS and contact your system administrator to resolve the issue."

when creating the workflow in the AX, where as standard workflow is creating.

Solution :  Generate Full CIL +Synchronization of all the tabels will relieve you from this error.

Regards,

Wednesday, November 19, 2014

Code to print Ledger journal balance in AX

static void AlfasithPrintLedgerBalance(Args _args)

{

    LedgerBalanceMainAccountAmounts balance;

    MainAccountListPageBalanceParameters balanceParameters;

    MainAccount mainAccount;

    ;

    mainAccount = MainAccount::findByMainAccountId( "11120005");

    balanceParameters = MainAccountListPageBalanceParameters::construct();

    balance = LedgerBalanceMainAccountAmounts::construct();



    balance.parmAccountingDateRange(balanceParameters.getStartDate(),balanceParameters.getEndDate());

    balance.parmPostingLayer(balanceParameters.getPostingLayer());

    balance.parmIncludeOpeningPeriod(balanceParameters.getIncludeOpeningPeriods());

    balance.parmIncludeRegularPeriod(balanceParameters.getIncludeOperatingPeriods());

    balance.parmIncludeClosingPeriod(balanceParameters.getIncludeClosingPeriods());

    balance.parmIncludeClosingPeriodBySystem(balanceParameters.getIncludeClosingPeriods());


    balance.calculateBalance(mainAccount);


    info(strFmt("%1", balance.getAccountingCurrencyBalance()));

}

Tuesday, November 4, 2014

15 - 40 Minutes full compilation of AX using CMD prompt

Hi,

cd C:\Program Files\Microsoft Dynamics AX\60\Server\MicrosoftDynamicsAX\bin
Here \\MicrosoftDynamicsAX\\ represents the Instance name that you given while installing.

axbuild.exe xppcompileall /aos=01 /altbin="C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin" /workers=4
aos = 01 is the SI NO. you can find that SI for your instance in server configuration.




Reference page : http://msdn.microsoft.com/library/d6da631b-6a9d-42c0-9ffe-26c5bfb488e3.aspx

Regards,
Mohamed Alfasith

Monday, November 3, 2014

Access the other instance DB belongs to same domain but different DB in AX

Hi,

static void AlfasithOtherDBAccess(Args _args)
{
    LoginProperty       loginProp;
    ODBCConnection      conn;
    Resultset           resultSet, resultSetCount; // get record
    Statement           statement1, statement2; // Create SQL Statement
    ResultSetMetaData   metaData ; // get Record metadate like columnname.
    RetailTillLayout    RetailTillLayout;
    int i = 1;
    ;

    // Set Server Database
    loginProp = new LoginProperty();
    loginProp.setServer('DNWADY0046L'); // System or  server name
    loginProp.setDatabase('MicrosoftDynamicsAX'); // instance DB name like MicrosoftDynamicsAX_Live

    // Create Connection and SQL Statement
    conn = new ODBCConnection(loginProp);
    statement1 = conn.createStatement();
    resultSet = statement1.executeQuery("SELECT TOP 1 * from [MicrosoftDynamicsAX].[dbo].[RetailTillLayout]");

    while (resultSet.next())
    {
        metaData = resultSet.getMetaData();
        while (i)
        {
            info("Column Name :"+metaData.getColumnName(i)+ " Value = "+resultSet.getString(i));
            i++;
        }
    }
}

Regards,

Get a table ID in SQL / table browser - D365

Hi select ID from SysTableIdView where  SysTableIdView .Name = 'CustTable' <URL>/?cmp=<CompanyID>&mi=sysTableBrowser...