Thursday, November 16, 2017

Dynamics AX Date Calculator : How to get The difference between two date in ax 2012 in detail years months days


You often try to calculate the differences between two dates using the available functions in dynamics ax for dates. However, for example I have two dates such as start date = 07/07/2007 and end date = 01/11/2016 where date caculator would show difference like 9 Years 3 Months 25 Day. What if the same detail calculation I have to perform in X++. This post will save your time since we might sometimes require this code during ax programming.
 static void AXDateCaculator(Args _args)  
 {  
     int monthsDiff, daysDiff, yearsDiff;  
     date emergingDateMth, emergingDateYear;  
     str dateCalculated;  
     //Dates can be changed here  
     date startdate = mkDate(7, 7, 2007);  
     date endDate  = mkDate(1, 11, 2016);  
     ///  
     yearsDiff                  = intvNo(endDate,startDate,IntvScale::Year);       
     emergingDateYear              = DateMthFwd(startDate, yearsDiff*12);                          
     monthsDiff                 = intvNo(endDate,emergingDateYear,IntvScale::YearMonth);  
     if (monthsDiff < 0)  
     {    
       yearsDiff                = yearsDiff - 1;  
       emergingDateYear            = DateMthFwd(startDate, yearsDiff*12);                          
       monthsDiff               = intvNo(endDate,emergingDateYear,IntvScale::YearMonth);  
     }  
     emergingDateMth               = DateMthFwd(emergingDateYear, monthsDiff);  
     daysDiff                  = intvNo(endDate,emergingDateMth,IntvScale::MonthDay);  
     if (daysDiff < 0)  
     {  
       monthsDiff               = monthsDiff - 1;  
       emergingDateMth            = DateMthFwd(emergingDateYear, monthsDiff);  
       daysDiff                = intvNo(endDate,emergingDateMth,IntvScale::MonthDay);  
     }   
     if (yearsDiff)  
     {  
       dateCalculated             += strfmt(" Years: %1", yearsDiff);              
     }   
     if (monthsDiff)  
     {  
       dateCalculated             += strfmt(" Months: %1", monthsDiff);             
     }  
     if (daysDiff)  
     {  
      dateCalculated             += strfmt(" Days: %1", daysDiff);              
     }  
     info(dateCalculated);   
 }  
After you execute this code you will see this result:
Happy Daxing :)!

Wednesday, November 8, 2017

Microsoft Dynamics AX 2012 R3 on VMWare

We recently established our VMWare environment for AX but while putting all best hardware, we found sometime very slow performance. I reviewed all the practices offered by Microsoft even we are higher in specs but I believe this could not solve our problem. I also visited few clients who are using MS AX on Virtual environment and they all faced the same problem. I got a recommendation to move DB (SQL) server from VM to Physical. Will that resolve the issue. We have never gone beyond 75% where CPU or Memory but sometime even on 50% of CPU usage, windows gets hanged. I have installed RDS (Remote Desktop Server) and everyone logs in through RDWEB.
Can anyone who gone through this phase guide me to optimize my environment, We have 5 locations connected through MPLS and each MPLS connectivity is approx 2MB connection.
  • Transportation management
    Get global transportation planning and freight reconciliation.
  • Budget planning
    Create easy-to-use budget plan worksheet templates for Microsoft Excel.
  • Modern point of sale (POS)
    Engage with rich clienteling, real-time inventory lookup, and back-office capabilities.

For a complete list of functionality and more information, see the product sheet.

Microsoft Dynamics AX is a
client
and
server
system that contains
a
data
layer
,
business logic
layer
, and presentati
on
layer
.
Th
is document
describe
s
a
reference
architecture for
a fully
virtualized Microsoft
Dynamics AX
implementation
enabled by
EMC VNX
5400
.
.
NET Business
Connector
Internet Information Server
(
IIS
)
Microsoft SharePoint
WSS web
parts
Dynamics AX web
parts
Role Center
Sites
,
pages
Business Logic
Server Session Manager
SharePoint
Databases
Dynamics AX
databases
SQL Server
Application Object Server
(
AOS
)
Dynamics AX Enterprise Portal Server
Dynamics AX
Windows clients
Enterprise Portal web
clients
Developers
MorphX
Visual
Studio
.
NET Business
Connector
Dynamics AX Enterprise Framework
Figure 2.
Logical architecture of a Dynamics AX environment
Figure
2
s
hows the
major components in
a Dynamics AX environment
:
Dynamics AX Enterprise Portal
, which is built on top of SharePoint Server
and
provides a web
-
enabled
interface for end
-
users
Dyna
mics AX
Application Object Server (
AOS
)
, which
handles
business logic
SQL Server
provides data management
for Dynamics AX business models and
transactions

Friday, November 3, 2017

Models Projects and Packages in D365


Today we will highlight an important architectural change in Dynamics AX 365. In AX 2012, the only option we had was over-layering for any sort of customization/modification in the out of box functionality. We had models/projects as set of elements, as the part of a given layer. Each layer can have one or more models/projects. Models can be exported to files that have the .axmodel extension and projects can be exported to xpo file. In Ax 2012, models files and XPO's are used for deployment purpose. 

How do we customize or modify any element in DAX365?

In DAX365, we have same elements reside in Application Explorer and these elements are objects such as tables, forms and classes, menu items etc. Customization of any object is done once it is added into a project and a project is linked or associated with a model.

Model:

Unlike AX2012, In DAX365, creating a model is mandatory thing for any sort of customization. A particular model can contain multiple Visual Studio projects. Therefore you can say it is a collection of projects and a single project can have all or subset of elements from originating model. However, association of a project is only with a single model. It is basically a unit of development/customization. Metadata for models is stored locally on an XML file called a descriptor XML.

Package:

As it is already mentioned that previously in AX 2012, we used XPO's and model as deployment unit. However in DAX365, we have packages for deployment purpose. A package may contain one or more models. In addition to elements of the model, this also includes model metadata which is the description data that define the properties and behavior of the model.  Also a package can be exported to a file which can then be deployed into a staging or production environment. In other words, you can say package is an independent set of layers and models.  It's also a set of folders that consists of XML files representing the elements in the system. In this way, a package can be viewed as a mini model store. Physically package translates directly to unit of compilation which is an assembly or DLL file. Packages can reference other packages that is similar to how .NET assemblies can reference each other.

Packages References:

Referencing a packages is useful, when it is required to reuse a functionality that exists in to another package. In this way, one or more packages can be combined to create a deployable package. And lastly, XML files are stored in the model directory that sit inside the package directory.

Layers:

Layers are the traditional AX concept but in D365, there is a new process where we extend layers as shown below.


Also when you create your model, you specify which layer the model is going to live in. However the importance of layer is quite minimal for instance, you are not required to provide a key for your model to live in that layer. Previously layers were single stack of code that over-layered upon each other. This new process uses layers but they are located in independent stacks.

This was only an architectural overview of Dynamics AX 365, I would further elaborate how do we customize the elements with some examples.

Go through links for further explanation and understanding and share your feedback on the post in comments section.