Monday, 19 September 2011

what´s difference between Kernel version and Application


The Dynamics AX Kernel is the component executing the X++ Application code. So the Kernel version is the version of the executable (Client, Server, Business Connectors) while the Application version is the version of the Dynamics AX “Business Logic” - the X++ Application code, Forms, Repots – everything in the AOT.
You can check the current Application version in the Dynamics AX Client going to "Help - About Microsoft Dynamics AX".

Monday, 11 July 2011

Sample union query from AX 2009

Queries build with the Query classes now supports unions, meaning that you can combine the result from several tables into one result set. The results you want to combine from the different tables must be structured the same way for all tables.

You could for example create a query combining CustTable and VendTable. This would be particularly useful if you need to present for example a lookup form showing both customers and vendors in the same grid. In earlier version you’d have to push customer and vendor data to a temporary table before being able to present the combined data in one grid.

Here is an example on how to build and use a union query from X++:






static void union(Args _args)
{
    Query                query;
    QueryBuildDataSource qbdsCustTable;
    QueryBuildDataSource qbdsVendTable;
    QueryRun             queryRun;
    CustTable            custVendTable;
    Map                  mapTableBranches = new Map(types::Integer, typeId2Type(typeId(TableId)));
    SysDictTable         dictTable;
    ;


    // The map is used to match the UnionBranchID with a table id
    mapTableBranches.insert(1, tableNum(CustTable));
    mapTableBranches.insert(2, tableNum(VendTable));


    query = new Query();
    query.queryType(QueryType::Union);


    qbdsCustTable = query.addDataSource(tableNum(CustTable));
    qbdsCustTable.unionType(UnionType::UnionAll); // Include duplicate records
    qbdsCustTable.fields().dynamic(false);
    qbdsCustTable.fields().clearFieldList();
    qbdsCustTable.fields().addField(fieldNum(CustTable, AccountNum));
    qbdsCustTable.fields().addField(fieldNum(CustTable, Name));


    qbdsVendTable = query.addDataSource(tableNum(Vendtable));
    qbdsVendTable.unionType(UnionType::UnionAll); // Include duplicate records
    qbdsVendTable.fields().dynamic(false);
    qbdsVendTable.fields().clearFieldList();
    qbdsVendTable.fields().addField(fieldNum(VendTable, AccountNum));
    qbdsVendTable.fields().addField(fieldNum(VendTable, Name));


    queryRun = new QueryRun(query);
    queryRun.prompt();


    while (queryRun.next()) 
    {
        custVendTable = queryRun.getNo(1);
        dictTable = SysDictTable::newTableId(mapTableBranches.lookup(custVendTable.unionAllBranchId)); 


        info (strFmt("%1 %2 (%3)", custVendTable.AccountNum,
                                   custVendTable.Name,
                                   dictTable.name()));
    }
}


  

Tuesday, 17 May 2011

Who Modified Ax2009 Object?


Following code will help you that who have modified object last time with date. Copy code and paste it in job. 

static void UserWhoModifiedObjectLastDateandTime(Args _args)
{
UtilIdElements tblUtilIdElements;
;
while select tblUtilIdElements
where (tblUtilIdElements.utilLevel == UtilEntryLevel::USR && tblUtilIdElements.recordType == UtilElementType::Form && tblUtilIdElements.name == "SalesTable")

{

info(strfmt("%1",tblUtilIdElements.modifiedBy + " " + datetime2str(tblUtilIdElements.modifiedDateTime)));
}
}

Tuesday, 5 April 2011

How to check if your variable suit the conditions given in query range

Use inRange methods from Global class

static boolean inRange(str _rangeValue, anytype _value)

Example:

{

str _rangeValue;

str _value ;

boolean result;

;

_rangeValue = ‘200..500’;

_value = ‘300’;


result = Global::inRange (_rangeValue , _value);

}

The result variable will be equal to true


How to set focus when first time opening form in axpta

Override method firstField on a form, and call after super method setFocus of a control which should focused after form is opened. Example:

public void firstField(int _flags=1)
{
;
super(_flags);
MyControlName.setFocus();
}