Thursday, February 23, 2017

Difference between Refresh(), ReRead(), ReSearch(), ExecuteQuery() on Form Datasource

While working on Dynamics AX forms, we come across using data source methods like Refresh, ReRead, ReSearch, and ExecuteQuery(). These methods often confuse the developer.

Following is an explanation of what their purpose is and when to use these methods:

Refresh(): Refreshes the user view with what‘s stored in the caches. This does not touch the DB.Use this after any form change has been made through code.

ReRead(): Fetches only the current record from database and does not re read the complete DataSource.Use this when you need to update only the current record after modifying any value.

ReSearch(): Will execute the same query again and fetch all the results from the database.Use this if you need to get the current most data from database.

ExecuteQuery(): Will run the query again just like research does but it will also take any query changes into account.Use this if you have modified the query on run-time and need the updated results according to the new query.

Thanks, hope it helps !!

Monday, February 20, 2017

Temp Table pros and cons - Dynamcis AX

Most of the time we require Temp Tables in our solution. This post is about temp table's capabilities, limitations and life-cycle.

When we use temp tables, axapta kernel creates a table in SQL temp database with a different name.

Capabilities:

  • Can be joined with normal tables in X++
  • Can save Data Per Company
  • Can be used in Enterprise Portal development
  • Can have foreign keys from other tables
  • Can have Indexes

Limitations:
  • Cannot be a Valid Time State Table
  • Cannot have Delete Action
  • No Record Level Security (RLS)
  • No View support (cannot be used in views)
Life-Cycle: When is temp table dropped from TempDB?
  • Table buffer goes out of scope
  • Restart of AOS service
  • Restart of SQL service
  • Closure of AX32.exe

Hope it helps !!!

Sunday, February 19, 2017

Table inheritance in Dynamics AX 2012

Microsoft Dynamics AX 2012 supports table level inheritance.
A table can extend from another table if its SupportInheritance property is set to Yes. Otherwise the table cannot extend from another table.

When a table A is created:

  • It is default inherited by Common table, this value cannot be seen in the table Extends property
  • When a variable (or buffer) of table A is declared, this variable inherits class of xRecrod by default
Cannot inherit from any other table

















You need to set Extends property of a table to specify its parent table. When a table A inherits from table B:
  • Table A will contain all the fields of table B but you cannot see them in AOT view
  • When a variable (or buffer) is declared of table A, it will access all the methods of table B and methods available in xRecord class
Table has inherited from another table


















Hope it helps !!!

Saturday, February 18, 2017

System fields of tables in Dynamics AX

When we create table in Dynamics AX, we create fields in that table. Those fields are then created as columns in the SQL database. These are called Custom Fields.

The AX framework manages some fields by itself, these are called System Fields. Some of the system fields are automatically generated (with a table property value set to Always in below table) and some fields are created on the choice of the developer.

To create the desired system field on your table you need to set table's property according to the following table:


System field
Table property
RecId
Always
RecVersion
Always
DataAreaId
SaveDataPerCompany = Yes
CreatedBy
CreatedBy = Yes
CreatedDate
CreatedDate = Yes
CreatedTime
CreatedTime = Yes
CreateTransactionId
CreateTransactionId = Yes
ModifiedBy
ModifiedBy = Yes
ModifiedDate
ModifiedDate = Yes
ModifiedTime
ModifiedTime = Yes
ModifiedTransactionId
ModifiedTransactionId = Yes

Hope it helps !!!

Friday, February 17, 2017

How to improve performance of Display Method - Dynamics AX


Display methods are very useful but they affect the performance of your solution.

AX gives a mechanism to enhance the performance of display method by caching the display method.

There are two options to do that:

1) Override the FormDatasource init() method and add the following code:

    public void init()
    {
          super();
      
          DataSource_ds.cacheAddMethod(tableMethodStr(Table, displayMethodName), false);
    }


2) AX 2012 has also given a feature called Declarative Display Caching

    This allows us to enable caching by setting CacheDataMethod property to Yes, No or Auto.

Improving quality !!!

Thursday, February 16, 2017

Multiple form datasources and their LinkType property values (Passive, Delayed, Active, Inner Join etc.) explained - Dynamics AX

While development and customization of AX forms we often need to add multiple datasources on the form. But there is only one main data source on the form. Remaining are joined to the main or any of its dependent data sources.

Form data source 















For adding multiple data sources we need to set following properties:

Join Source: The data source to which chile (current) data source will be connected.
Link Type: Link type will specify the type of link that will be established with parent datasource.

Link type has following options:

Active: Active link type update the child data source without any delay when you select the master table record. This has performance problems when dealing with multiple records.

Delay: It is same as Active link type except it doesn't update the child data source immediately, it updates the child datasource when child table record is selected or set focus.

Passive: If this property is used as link type then the child datasource will not update automatically. You need to update child datasource manually in code by calling its executeQuery() method.

Inner Join: Inner join shows the data of child data source that matches the parent data source. Its like join of SQL.

Outer Join: It will return all parent records and matched child records.

Exists Join: It works like inner join but the difference is it only returns parent table records not the child table records.

Not Exist Join: It works completely opposite to Exists Join. Returns only those rows of parent table which are not matched with child table.

Hope it helps !!!


Tuesday, February 14, 2017

Difference between Refresh AOD, Refresh Data, Refresh dictionary on enterprise portal - Dynamics AX 2012

While development of Enterprise portal you might need to use following options:



















Refresh AOD:
This refreshes all the AOT elements except  elements in Data Dictionary node for example classes, data sets web menu items etc.

Refresh Data: Refreshes any static data that is used on enterprise portal sessions.

Refresh Dictionary: Refreshes the elements contained in Data Dictionary node of AOT for example tables, EDT, enums, views etc.