Tuesday, November 11, 2014

Difference between Overloading and Overriding

Overloading and overriding is done on methods and variables in classes.

Overloading: overloading of method is writing the same method with different number or different types of arguments in the same class. the method name will be same but arguments types or no. of arguments will be different.
X++ does not support method overloading and can't be used in AXAPTA.

Overriding: Overriding is writing a method implemented in parent class again in child class. 
Note that the parent class method again implemented in child class . So the method signature remains same and will not change. If we try the no. of arguments or type of arguments in child class we will get unexpected results.  

Thursday, November 6, 2014

Export and Import model files

A model is a set of elements in a given layer. 
Each layer consists of one system-generated model that is specific to that layer but we can also create  new models on a specific layer like USR or VAR.
Exporting a model file is very useful if you need to migrate all your customization from one environment to another environment. 

Export Model File:


Go to Administrative Tools>Microsoft Dynamics AX 2012 Management Shell
type the following command 

Export-axmodel -Model "ModelName " -File "path"

Ex: export-axmodel  -model  "usr model " -file "d:axmodel\usr_model" 

Import Model File:

install-axmodel -File"path" -details

Ex:  install-axmodel -file"d:axmodel\usr_model" -details 

Uninstall/Remove Model File:

uninstall-axmodel  -Model "ModelName"

Ex: uninstall-axmodel -model  "USR Model"

Wednesday, October 22, 2014

Method Modifiers

There are several modifiers that can be applied to method declarations.

Public: Methods that are declared as public are accessible anywhere the class is accessible and can be overridden by subclasses. Methods that have no access modifier are implicitly public.

Private: Methods that are declared as private can be called only from methods in the class where the private method is declared.

Protected: Methods that are declared as protected can only be called from methods in the class and in subclasses that extend the class where the method is declared.

final: Indicates that the method cannot be overridden in any class that derives from its class.

Server: Establishes the location where the method is to be executed (on the server).
Can only be used on static methods. If the method is not static, you need to specify the location using the class property RunOn.

Client: Establishes the location where the method is to be executed (on the client).
Can only be used on static methods. If the method is not static, specify the location by using the class property RunOn.

abstract : The method is declared but not implemented in a parent class. The method must be overridden in subclasses.
If you try to create an object from a subclass where one or more of the abstract methods belonging to the parent class have not been overridden, you will get a compiler error.
Ex: SalesFormLetter

static: Specifies that the method is a class method and does not operate on an object.
static methods cannot refer to instance variables and are invoked by using the class name rather than on an instance of the class (MyClass::aStaticProcedure()).

Display: Indicates that the method's return value is to be displayed on a form or a report. The value cannot be altered in the form or report. The return value is typically a calculated value,
for example, a sum.

edit: Indicates that the method's return type is to be used to provide information for a field that is used in a form. The value in the field can be edited.

Monday, October 20, 2014

How to enable debugger

I am trying to set debugger showing a warning
"X++ debugging is not enabled for code running on Application Object Server"

Solution: open Ax Server Configuration>In Application Object Server tab set to true enable breakpoints to debugg X++ code running on this server



 
 
 
 
 
 

update_recordset with joins

 update_recordset with joins update_recordSet storeTransfer         setting      TransactionId = transfertable.TransferId     join transfert...