Thursday, 30 June 2016

Cache in Dynamics Ax 2012

Caching Mechanism in AX:

Caching in simple terms, is a temporary storage area where frequently accessed data can be stored for rapid access. Once the data is stored in the cache, it can be used in the future by accessing the cached copy rather than re-fetching or recomputing the original data.

In Ax, we have 2 caches.

1.Server Cache
2.Client Cache

Client Cache is used only when a select is executed on client-tier. If a record is not in client cache, it looks in server Cache, and if not, it costs a database fetch. Maximum records stored in client cache are 100 per table, per company, where as, in ServerCache, this limit is 2000.

To know whether a record is fetched from client cache, server cache or database, use wasCached() of the TableBuffer used in Select.

select * from salesTable where salesTable.salesId == '000006';
info(strfmt("%1",salesTable.wasCached()));

We have 2 types of caching mechanisms in Ax:

  Set Based Cache – Caches a set of records.(EntireTable)
  Single-record Cache – Caches records based on Select Statement used.(NotInTTS, Found, FoundAndEmpty)

None: No data is cached or retrieved from the cache for this table.
This property value should be used for tables that are heavily updated or where it's unacceptable to read outdated data.

The Found and FoundAndEmpty caches cross transaction boundaries. The NotInTTS cache is newly created inside a transaction. This example, modified for the purposes of this topic, demonstrates how records are retrieved from the cache when the table's CacheLookup property is set to NotInTTS, and the PrimaryIndex property is set to a unique index on the AccountNum field.

Ex:

static void NotInTTSCache(Args _args) // X++, in AOT > Jobs.
{
    CustTable custTable;
    ;
    // The query looks for a record in the cache.
    // If the record does not exist in the cache,
    // the query accesses the database.
    select custTable
        where custTable.AccountNum == '4000';

    // The transaction starts.
    ttsbegin;

    // The cache is not used. The query accesses the database
    // and a record is placed in the cache.
    select custTable
        where custTable.AccountNum == '4000';

    // The query uses the database because
    // the forupdate keyword is used.
    select forupdate custTable
        where custTable.AccountNum == '4000';

    // The query uses the cache and not the database.
    select custTable
        where custTable.AccountNum == '4000';

    // The query uses the cache because
    // the forupdate keyword was used previously.
    select forupdate custTable
        where custTable.AccountNum == '4000';

    // The transaction is committed.
    ttscommit;

    // The query will use the cache.
    select custTable
        where custTable.AccountNum == '4000';
}

If the table CacheLookup property was set to Found or FoundAndEmpty, the first select statement inside the transaction (after the TTSBegin statement) would retrieve the record from the cache.

In AX 2012, table caching is more advanced than in previous versions, including support for joins, unique indexes (as opposed to primary indexes only), cross company queries, etc. (under certain constraints as explained in the above links).

Links:
https://msdn.microsoft.com/EN-US/library/bb314693.aspx

https://community.dynamics.com/ax/b/axsupport/archive/2015/02/20/dynamics-ax-table-caching-basic-rules
http://tech.alirazazaidi.com/exploring-data-cache-in-dynamics-ax-2012/

Monday, 27 June 2016

The history of Dynamics AX / Axapta

The history of Dynamics AX / Axapta

Microsoft Dynamics AX is originally developed the Danish company Damgaard A/S as Axapta. In 2002 Damgaard A/S merged with Navision Software A/S, into NavisionDamgaard A/S, eventually ended up calling them Navision A/S

The development and modification of software is done by its own integrated development environment, MorphX, which contains several tools such as a debugger, profiler and query interface. The development environment remains the same client application, thereby allowing access to these tools from the client application. The language used in Axapta is X ++.

1998 - Axapta 1.0 is released in March.

Released in the US and Denmark
Financial, trade, inventory management, logistics and production, Microsoft SQL Server 6.5
1998 - Axapta 1.5 - Early release in Norway, Sweden, Germany, UK, Netherlands, Austria, Switzerland, Belgium Spain and the European Union.

Publishing Manager
Call COM
Service Pack technology
Microsoft SQL Server 7.0

1999 - Axapta 2.0 - July:

Project Accounting module
WMS
External OLAP
Option Pack concept
ActiveX support
COM-connector and an early release of Axapta Object Server

2000 - Axapta 2.1 - January: Market demands from Germany, Austria, Switzerland and Spain.

Web tools and CSS (The first WebApp)
Microsoft SQL Server 2000, database log.
Receives Microsoft Windows 2000 logo.

2000 - Axapta 2.5 – December: Complete Web applications development environment.

Auto upgrade tool
ESS (Project)
Banking
First step of Load’n’Go
OLAP within Axapta
XML support
FA to Denmark, Austria and UK. Domains and ASP support
DBCS Support.

2001 - Axapta 2.5 Market Pack – October: Released in France and Italy.

Marketing Automation (CRM)
Commerce Gateway
Product Builder (Web application as well), training
Event Management (Web application as well).

2002 - Microsoft Axapta 3.0 - October:

Microsoft Axapta Enterprise Portal, intercompany collaboration.
New security and configuration keys.
Expanded geographical reach (more countries).
Demand planning.
Enhanced partner productivity tools.

2006 - Dynamics AX 4.0  - March:

  The seventh major Axapta release brought with it an updated look and feel. As the first version that Microsoft was involved in from the beginning it attempted to integrate better with existing Microsoft technologies.

AOS became a true Windows service
.Net business connector was provided
CLR Interoperability was introduced
XML data exchanges were supported through a set of code classes (Application Integration Framework)
Full Unicode support was introduced
Service Management module.

2008 - Dynamics AX 2009  - June: 

Originally named AX 4.1, later renamed to AX 5.0 (and finally AX 2009), the eighth major release of Axapta brings with it yet more improvements to the UI. This new version adds role-based concepts to both the Enterprise Portal and windows clients, support for timezones (utc), a new Site inventory dimension, and Enterprise Portal development through Visual Studio projects.

2011 - Dynamics AX 2011  - Q1:

 Sometimes dubbed AX 6, it is said to include additional improvements to the user interface and application enhancements focused on specific industries like Retail, Media & Entertainment, and Public sector. Originally AX 2011 was due to be released toward the middle of 2010, but this has since been put back to Q1 2011.

Dynamics AX 2012 Feature Pack:

 Released soon after AX 2012, the feature pack added a Retail solution in addition to the previously released industry-specific solutions.

Dynamics AX 2012 R2:

 Announced at the Convergence 2012 conference, AX 2012 R2 is due to ship in late 2012 and is expected to include enhanced support for Microsoft SQL Server 2012 as well as support for additional languages and markets

Tuesday, 14 June 2016

updating InventTrans when a line in PurchLine or SalesLine is created

I had a weird customization in the recent days and I wanted to share it with you guys. It is in AX 2012.

Our functional team wanted to add a column in the purchLine(Table) form and it should reflect in the InventTrans(Table) form.

Note: To see the Invent Transactions form, Open PurchLine form > Inventory > View > Transactions.

Let me tell you in steps to get the things done.

Step 1: Add a column of a datatype of your interest into the PurchLine Table and InventTrans Table.

Step 2: Open InventMovement class and add a new column for the above field to update it to InventTrans Table when a PurchLine is created and it should return an empty value. Check ProjId method for your reference.

Step 3:  Perform a Forward compilation to make the child classes of the InventMovement class to know about the above method.

Step 4: Override the above method in InventMov_Purch class and return PurchLine.yourfield.

Step 5: Finally, In the classes \Classes\InventMovement\initInventTransFromBuffer do the assignment. Eg: InventTrans.yourField = this.createdmethod(); (look at projId implementation)

Step 6: Compile the class InventMovement and done.

Now, the newly created field of the PurchLine should reflect in InventTrans form.

Leave the comments if you get any queries while performing it.

http://dynamicsuser.net/ax/f/11/t/75821