Wednesday, 17 February 2016

How to create dynamic Query in AX 2012



Using below code, CustTables and SalesTable  are joined at run time (dynamically)

Open AOT. Create new Job named CustTableSales

static void CustTableSales(Args _args)
{
    Query       query;
    QueryRun    queryrun;
    QueryBuildDataSource    qbds1;
    QueryBuildDataSource    qbds2;
    QueryBuildRange         qbr1;
    QueryBuildRange         qbr2;
    CustTable               custTable;
    ;
    query   = new query();
    qbds1   =   query.addDataSource(tablenum(CustTable));
    qbds1.addSortField(fieldnum(custTable,AccountNum),Sortorder::Descending);
    qbr1    = qbds1.addRange(fieldnum(custTable,custGroup));
    qbr1.value(queryvalue('10'));
    qbr2    =  qbds1.addRange(fieldnum(custTable,Blocked));
    qbr2.value(queryvalue(CustVendorBlocked::No));
    qbds2   = qbds1.addDataSource(tablenum(SalesTable));
    qbds2.relations(false);
    qbds2.joinMode(joinmode::ExistsJoin);
    qbds2.addLink(fieldnum(CustTable,AccountNum),fieldnum(SalesTable,CustAccount));
    queryrun    = new queryrun(query);
    while(queryrun.next())
    {
    custTable   = queryrun.get(tablenum(custTable));
    info(strfmt("%1 - %2",custtable.AccountNum,custTable.Name));  

   // Check output
    }
}

Types of tables in AX 2012


Prior to Dynamics AX 2012 versions, only one type of temporary table was available. In AX 2012, however, the Temporary property on tables was replaced with a new property: TableType, which has three possible values:

  •         Regular - a standard physical table
  •         InMemory - the type of temporary table which existed in the previous versions of Dynamics Ax. Such tables are held in memory and written to a local disk file once they grow beyond a certain point
  •         TempDB - a new option in Ax 2012. They are "physical" temporary tables held in the SQL Server database.

TempDB tables
We call them TempDB tables because their TableType property value is TempDB. This value comes from the TableType::TempDB enum value. The TableType property value can be set at AOT > Data Dictionary > Tables > MyTempDBTable > Properties > TableType.
 
The new TempDB tables operate in a similar manner to InMemory tables but support more features from standard physical tables:

  •   More powerful joins with physical tables are possible, and are properly supported by the database
  •   Can be per-company or global
  •    Support for normal tts transactions
 
 
In a developer's point of view, temporary tables store data in the same way as
 normal physical tables, except that the data is automatically dropped when no longer required.
 



 


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Difference between AX-2009 to Ax-2012


There are many difference. Below are few points:

Models and the Model Store

Object IDs

The AxUtil Command Line Utility and PowerShell Cmdlets

Development Workspace

Some Layers Have Been Renamed

S.No Microsoft Dynamics AX 2009 Microsoft Dynamics AX 2012 Why is this important?
1.Models and the Model Store The model store did not exist in Microsoft Dynamics AX 2009. Application model data was stored in .aod files. You can load .aod files during version upgrade. You can also load .aod files by using the Tools menu. The following model features are new:
1. A model is a set of model elements in a specific layer.
2. Each layer consists of one or more models. One of the models is generated by the system. For example, VAR Model is the model that is generated for the VAR layer.
3. Each element in a layer must belong to only one model.
4. Models can be exported to a file artifact that is called a model file. Model files have an .axmodel extension. A model file is like an .aod file from earlier versions, but the names and numbers are not limited. Models in the model store can be exported to model files and imported from model files. Model files can be signed, and the signature is verified when the model files are installed.
5. Model files replace .aod files as installation artifacts.
6. Models in the SQL Server–based model store replace .aod files that were used at run time.
7. The Application Object Tree (AOT) shows you which model a particular element belongs to, in addition to the layer tags.
 
Storing models in SQL Server increases quality, reliability, and performance. In addition, you can use the tools that are available in SQL Server for backup and administration
2.Object IDs Object IDs were 16 bits long Object IDs were 32 bits long Changing the length of object IDs from 16 bits to 32 bits exponentially increases the number of object IDs that are available
3. The AxUtil Command-Line Utility and PowerShell Cmdlets The feature was not available AxUtil is a command-line utility that you can use to import and export .axmodel files into the SQL Server model store. You can also use AxUtil to delete one or more models, create new empty models, and list all of the models in a layer.
All of the capabilities of AxUtil are also exposed as PowerShell CmdLets.
Users can use these tools to work with models from outside the development environment. Therefore, there are more options for scripting deployment processes
4.Development Workspace Development occurred directly in the Application Workspace The Developer Workspace contains all of the tools and features that a developer must have to create and customize a Microsoft Dynamics AX application. Changes that you save in the Development Workspace are always synchronized with the Application Workspace. You can still open application elements in the AOT. You can also open an Application Workspace from the Development Workspace to view your customizations.
You can open Microsoft Dynamics AX directly from a Development Workspace by using the Ax32.exe command-line flag
The new Development Workspace provides a more streamlined environment for writing code. The menus have also been customized to make it easier to find the tools and commands that you use when you write code

Sunday, 14 February 2016

Dynamics AX 2012 - Labels are not showing correct after Minor upgrade from AX 2012 to AX 2012 R3

If labels are showing like @SYS305949 after upgrade from Microsoft Dynamics AX 2012 to AX 2012 R3.
Resolution:
Try to do these steps one by one and check whether your labels files are appearing:
1.    Restart the AOS(s) to ensure that the change takes place.
•    Press Window + R.
•    Type services.msc then Press OK.
•    Services form will get open as shown in below screenshot.



  •     Select Microsoft Dynamics Ax Object Server….** service.
  •     Press Restart 

2.    Export the label files (AOT > Label files) and then Re-imported it and restart the AOS once.

Export Label File:
Open AOT, Expend Label node. Choose Label file of required language to export e.g.  en-us. You can do it for individual language or you can select multiple language all in once.




Exported file will save on selected path with extension “.ald”.

Re-import same label file which you exported

Right click on Label node in AOT and select “Create from File”, choose ald file to import then click create.

Restart AOS Once:
Follow steps shown in point 1
3.    Do Tools/caches refresh Elements, Refresh Dictionary and Refresh Data

Open Ax client then open Application object tree (AOT).
Go to Tools Menu=> Caches
You can click one by one: Refresh dictionary, Refresh data and Refresh element.

   4.    Generate incremental CIL.