Wednesday, November 16, 2011

How to decide the RunOn property value in Dynamics AX?

While working with Client-Server programming, code placement is crucial to decide otherwise it will results in performance hit. Let's have a look at RunOn property of different AOT objects.

Classes
-     The value of RunOn property for a class will be same as the parent class if the parent class has a RunOn property other than Called from i.e. the RunOn property cannot be changed for a class if the parent class has as its value either Client or Server. 
-     If the parent class has Called from as its RunOn property value, it can be changed to Client or Server and if it is not changed it will retain the inherited value i.e. Called from.
-     The Called from value of the RunOn property means the object will live at the tier where the code creating it (by calling the new constructor) is running.

Methods
-     Class static methods and table methods (except for the database methods) can have their default behavior.
-     The execution place for a method can be changed to Server or Client by adding the Client or Server modifier keywords in the method declaration as shown below:
o    server static boolean mymethod(): to make server the execution place.
o    client static boolean mymethod(): to make client the execution place.
o    client server static boolean mymethod(): to make called from the execution place.

GUI Objects and Reports
-     GUI objects always live on Client. GUI objects include the FormRun, FormDataSource, all FormControls, DialogBox, and OperationProgress objects.
-     Reports always live on Called from, which means the object will live at the tier where the code creating it (by calling the new constructor) is running.

Temporary Tables
-     Temporary tables instantiate and live at the tier where data is first inserted and it does not matter where they are declared. Since the placement of temporary tables is very critical for performance, temporary tables should live at the tier where they are used. If a table is utilized in more than one tier then it should live on the tier where the greatest number of inserts and updates are performed.

Queries
-     QueryRun has called from as the default value of the RunOn property. The QueryRun should always be supplied from the same tier from where it was originally run.
-     If you want to create a new QueryRun in place of an old one, it should be created on the same tier where the old QueryRun was executed.