Tuesday, August 23, 2016

Dynamics AX - The value 1 is not found in the map

Issue Resolved. The problem was in the progress bar. The workaround is to use the SetTotal(someinteger) method instead of the incCount() method .

Monday, August 8, 2016

Ferranti DateTime Conversion to Date

Ferranti  DateTime Conversion to Date

IIF (b.bilstartdate = '0','0',CONVERT(VARCHAR(12),DATEADD(day, -2, (36526+(LEFT( b.bilstartdate + 288000000000,11)-63082281600)/(24*3600))),5) )as startdate

Thursday, August 4, 2016

Executing SQL Query in Dynamics AX

X++ language supports a number of ways to execute native SQL against any SQL data source.

Note: don't forget to set RunOn Property to Server of the class. Job:

static void BillingQuery(Args _args)
{
    RunSqlQuery q = new RunSqlQuery();
    q.RunSqlQueryMethod();

}

Class:

class RunSqlQuery
{
}

public void RunSqlQueryMethod()
{
     str sql;
    Connection conn;
    SqlStatementExecutePermission permission;
    Statement Stmt;
    ResultSet R;
    str result;
    ;
    sql = "select ACCOUNTNUM from custTable";

    conn = new Connection();
    permission = new SqlStatementExecutePermission(sql);
    permission.assert();

    Stmt = conn.createStatement();
    R = Stmt.executeQuery(sql);
    while ( R.next() )
    {
        result =  R.getString(1);
    }

    // the permissions needs to be reverted back to original condition.
    CodeAccessPermission::revertAssert();
}

Below the useful links.

http://blog.rahulsharma.in/2010/04/dynamics-ax-sqlstatementexecutepermissi.html

https://msdax.wordpress.com/2010/06/21/executing-sql-directly-from-x/

Wednesday, August 3, 2016