AX Tech basics


Class
The X++ language was designed with Java in mind, thus it is a single inheritance, type safe, object oriented language. It shares a range of basic properties with C#, Java, and VB.NET such as: classes, access modifiers, interfaces, abstract classes, polymorphic behavior of classes, overriding, and a standard API. X++ has inherited Macros and Functions from its legacy system XAL and these are important and widely used parts of the language. Some of these functions provide functionality similar to reflection and object metadata found in both .NET and Java.

Abstract Classes
An abstract class is a class that is used to create a common interface for a set of classes. There is a set of rules connected to using abstract classes. • The abstract class cannot be instantiated but other classes can inherit from this class. • An abstract class can have a number of abstract methods and normal methods. • An abstract method has no method body and must be overridden in subclasses. • When a class has an abstract method the class must be declared abstract. • An abstract class does not have to have any abstract methods.

Interfaces
An interface is a language feature that helps you organize and structure your classes and their relationships with one another. The purpose of defining an interface is to define a protocol of behavior that can be implemented by any class anywhere in the class hierarchy. Interfaces are useful for the following: • Capturing similarities between unrelated classes without artificially forcing a class relationship. • Declaring methods that one or more classes are expected to implement. An X++ interface is a class without implementation. It can have any number of methods with access modifier, return type and arguments but no method body. In that respect interfaces are similar to purely abstract classes but interfaces are not extended they are implemented. When a class is implementing an interface the class promises to provide the implementation of all methods in that interface.


Classes and objects

Classes
A class is a software construct that defines the data (state) and methods (behavior) of the specific concrete objects that are subsequently constructed from that class. A class is built out of members, which are either variables or methods. Variables are the data for the class. Methods are the sequences of statements that operate on the data, and define the object's behavior.
Interface & implements

An interface is a language feature that helps you to organize and structure your classes and their relationships to one another. An interface defines a set of methods but does not implement them. To use an interface, a class has to implement the interface. A class that implements the interface agrees to implement all of the methods defined in the interface, thereby agreeing to certain behavior. The purpose of defining an interface is to define a protocol of behavior that can be implemented by any class anywhere in the class hierarchy. Interfaces are useful for the following: Capturing similarities between unrelated classes without artificially forcing a class relationship. Declaring methods that one or more classes are expected to implement.

Constructors
When you declare a class in X++, you use the new method to perform initializations when you instantiate objects from that class. The new method in a class is called a constructor. Like other methods, constructors may take parameters but they never return values. Foundation classes The Microsoft Axapta foundation classes currently fall in five distinct parts: Sets, maps, lists, arrays and structs.

Lists
Lists are structures that may contain any number of elements that are accessed sequentially. Lists may contain values of any X++ type. All the values in the list must be of the same type, given in the creation of the list. The implementation of lists is such that traversal of the list elements is very fast. Lists may be traversed using the listIterator class.

Maps
A map is a data type that associates one (key) value with another value. Both the key and value values may be of any valid X++ type, including objects. The types of the key and the value are given in the declaration of the map. The implementation of maps is such that access to the values is very fast. Multiple keys may map to the same value,
but one key can only map to one value at the time: Adding a (key, newvalue) where the key already exists in the map will change the association such that key maps to newvalue.Maps may be traversed using the mapIterator class.

Sets
A set is a container class that may hold any number of distinct values. The values may be of any given X++ type. All values in the set must have the same type. Adding a value that is already stored in the set is ignored and does not increase the number of elements in the set. The elements are stored in a way that facilitates looking up the elements. The values stored in the set may be traversed using objects of type setIterator.

Arrays
Arrays may hold values of any one, given type, including objects and records . The values are stored sequentially.

Structs
Structs (short for structures) are entities that may hold a number of values of any X++ type. Structs are used to group information pertaining to a specific entity. For instance, it may be desirable to store information about a customer’s name, age and height and to treat this (compound) information as one item. Each named item is called a field. Each field may have a fieldname that denotes that particular field, but a field can exist without a fieldname. The field value is then accessed through the field’s index. Fields may be added at run time. The fields in a struct may be traversed using the fields, fieldName and fieldType methods. Structs may be packed into containers and later restored by using the struct::create method.

Overriding methods
If you are in a subclass and want to alter the functionality of a method in a super class, you can create a method with the same name and parameters as in the superclass. Preventing method overriding to protect sensitive or 'core' methods, X++ supports the final modifier, which prevents a method from being overridden. In every class there are two special methods: new and finalize. new is invoked automatically when an object is created. Neither of these methods may be specified as final. Static methods cannot be overridden as they exist per class. Hence, no final modifier is needed to protect static methods from being overridden.

Preventing class extension
You can also prevent classes from being extended by using the final modifier

Override Vs. Overload
Overload
To provide more than one method with the same name but with different signatures to distinguish them.
Override
To replace the superclass's implementation of a method with one of your own. The signature must be identical. Note Only non-static methods may be overridden.
Microsoft Axapta supports overriding, not overloading. Method access control All methods of a class are always available to code in the class itself. To control access from other classes, and to control inheritance by subclasses, X++ has three access control modifiers for methods:
Public
Methods declared public may be used anywhere the class is accessible and may be overridden by subclasses.
Protected
Methods declared as protected may only be called from methods in subclasses of the class where the protected method is declared.
Private
Methods declared as private may only be called from methods in the class where the private method is declared.
If you do not specify an access modifier, this is interpreted as if you had specified the public modifier.
Scopes in X++
In X++ variables and methods have a well-defined scope. A scope is the area in which an item can be accessed. A global item can be accessed from anywhere in the application. A local item can be accessed only within the current scope.

Exception handling
MorphX has a built-in exception-handling mechanism. This means that you can catch errors during program execution, and control how the program will react following an error. To use exception-handling, you must specify which statements are to be controlled by the use of throw and try respectively. The try statement has a catch list, where thrown exceptions are caught. You can nest try statements.

Data types in X++
Primitive data types in X++
Boolean
Booleans can only contain the values false and true. Note: A boolean is a special type of enum with two possible values. The enum values false and true are predefined in X++ and recognized by the compiler.
Integer
An integer is a number without a decimal point.
Real
Reals, also called decimals, are numbers with a decimal point.
Date
The date type contains day, month and year.
TimeOfDay
The TimeOfDay type contains hours, minutes, and seconds.
String
A string is a number of characters. X++ supports three kind of strings.
Enum
Enum is an abbreviation for enumerated text - a set of literals.
Composite data types in X++
Arrays
An array is a list of items with the same data type and same name; only the index differs.
Containers
A container is a dynamic list of items containing primitive data types and some composite data types.
Classes
A class is a type definition that describes both variables and methods for instances (objects) of the class.
Tables
All tables defined in the Axapta database can be handled as class definitions.
Extended data types Extended Data Types are user-defined types. On the basis of the primitive data types boolean, integer, real, string, and date and the composite type container, MorphX lets you create your own user-defined types. Macros MorphX has a built-in macro-preprocessor. The purpose of macros is to make statements easy to reuse and you can declare macros wherever you can write X++ statements. There are basically three kinds of macros: macros in macro libraries, stand-alone macros and (local) macros inside methods. All three types of macros have identical syntax and functionality. The only differences are that A stand-alone macro is created using the macro-node of the Application Object Tree A macro library is a stand-alone macro, which contains (local) macros A local macro is declared within a method, or stand-alone macro
Activating a menu item from your X++ code
To execute a menu item from your X++ code you use the MenuFunction system class.
Activating a class from a menu item
If you define a method on a class with the following profile void static main (args _args) you can activate it from a menu item.One of the class methods can subsequently instantiate and run the class.

1. Define System Class?
Ans. A system class is functionality implemented in MorphX, and used by MorphX, that has been exposed through an interface so you can use it. There are about 150 system classes in the system.FormDesign, shown below, is just one example of a system class. The system uses FormDesign when you define the layout of your form in the Designs node in the Application Object TreeThere are about 150 system classes in the system. It shows only. FormDesign, shown below, is just one example of a system class. The system uses FormDesign when you define the layout of your form in the Designs node in the Application Object Tree

2. What is object in Ax?
Ans. Object is the central MorphX concept. Any form or control is an object. The database is an object. Objects are created from classes; thus an object is said to be an instance of a class. Objects provide a convenient, logical way to organize procedures and data. Objects are encapsulated which means that they contain both their code and their data. To use an object, you must keep a reference to it in an object variable.

3. Define ClassFactory? And Where to use the ClassFactory class?
Ans. ClassFactory is the class instantiator, and has methods to instantiate different application objects. Two instances of ClassFactory always exist, one running on the client and one running on the server. The methods on ClassFactory must be used to instantiate forms, reports, and queries from X++ code.

4. Which of the following components of object-oriented programming is not supported by Microsoft Axapta?
– Overriding
– Inheritance
– Interface
– Overloading
A.Overloading.

5. How do you implement a constant in X++?
A.The value of a variable is always set to a new value in the current class or subclasses. Macro can be used to set constant values of simple datatypes .

6. What is the syntax for setting the default printer option to email in the printJobsetting class?
A. PrintJobSettings.setTarget(PrintMedium::Mail).

7. Can a job can be called?
a. Using TreeNode Class
i. Treenode::findNode('Jobs\\YourJob') ii. treeNode.AOTRun()

8. How do you call a report when you write X++ code?
a. By initiating the ReportRun object

9. What is ClassFactory?
ClassFactory is the class instantiator, and has methods to instantiate different application objects.

10. How can you change company.
changeCompany('<name of company>') { }

11. Function used to get list of Breakpoints in Application
a. Infolog.BreakPoint() returns Container

12. How to create number sequence for a new module?
http://daxguy.blogspot.com/2007/04/new-number-sequence-for-new-ax-module.html Steps to create number sequence for new module.
a. Create a new Enum (name with module name) under the NumberSeqModule.
b. Create a new EDT (name with module name).
c. Create a new Class (name with module name) extend the NumberSeqReference.
1. Create a new method called loadModule (). NumberSequenceReference numRef; ; numRef.DataTypeId = typeId2ExtendedTypeid (typeId (TestEDT)); //EDT numRef.referenceHelp = literalStr ("Test Number Sequence"); numRef.WizardContinuous = true; numRef.WizardManual = NoYes::No; numRef.WizardAllowChangeDown = NoYes::No; numRef.WizardAllowChangeUp = NoYes::No; numRef.SortField = 1; this.create (numRef); 2. Create a new static method called numberSeqModule (). Static NumberSeqModule numberSeqModule () { Return NumberSeqModule::Test; //Enum }
d. Modify the NumberSeqReference Class for the following methods.
\Classes\NumberSeqReference\moduleList Add the following code – use of this is, we are adding new module so we have to add the new module to existing moduleList container. ModuleList += NumberSeqReference_AboveCreatedClass::numberSeqModule (); //step: c \Classes\NumberSeqReference\construct Add the following code case (NumberSeqReference_PrePurchase::numberSeqModule()): Return new NumberSeqReference_PrePurchase (_module); MyNewId = NumberSeq::newGetNum (MyModuleParameters::numRefMyDataType ()).num ();

13. Which class is used to post a journal?
A. LedgerJournalCheckPost Class

14. Which class holds a list of transactions that are going to be posted for a particular voucher?
A. LedgerVoucher class

15. What is Singleton pattern
A singleton is a class which only allows a single instance of itself to be created. An instance of a singleton class is not created until the first time it is requested.

16. How MorphX Query classes are divided
a. Build Classes: Query/QueryBuildDataSource
b. Run Classes: QueryRun

17. Differentiate between QueryRun class and Query/QueryBuildDataSource... Classes
a. QueryRun: Work on a running instance of a query. This means that any modification made to a query at run time is local to this specific instance of the query,
b. Query/QueryBuildDataSource: They do not work on a running instance of an object, but rather on the specifications of the objects, that is on any of the query objects defined in the Application Object Tree. If a method is used in a Build class to modify a property for a query object, the specification of the query object can be modified. This means that the modification will take effect for the instances that are run later on.

18. How will you post ledger transactions by using X++ code? & from .NET application
http://daxguy.blogspot.com/2007/07/post-ledger-transactions-via-x.html 1. Using LedgerVoucherClass and 2. Using journal Class

1. In first method we should instantiate use three object for the following classes. They are The Classes are:

LedgerVoucher - Posting {LedgerVoucher harnesses the posting of multiple vouchers at a time. }
LedgerVoucherObject - Voucher {The LedgerVoucher class holds all the vouchers in temporary storage.}
LedgerVoucherTransObject – Transactions {Holds transactions in each Voucher}

Sample Code
LedgerVoucher _LedgerVoucher;
LedgerVoucherObject _LedgerVoucherObject;
LedgerVoucherTransObject _LedgerVoucherTransObject;
NumberSeq _NumberSeq;
Dimension _Dimension;
NumberSequenceCode _VoucherCode = 'Ledger_3'; // 'Ledger_3' is the voucher Numbersequence in the Path AX>General Ledger>Setup>Journals>Journal Names. Its the Voucher Numref for the Journal Name :)
LedgerAccount _Account = '110180';
LedgerAccount _OffsetAccount = '140270';
AmountCur _AmountCur = 12345.67;
ttsbegin;
_NumberSeq = NumberSeq::newGetVoucherFromCode(_VoucherCode);
_LedgerVoucher = LedgerVoucher::newLedgerPost(DetailSummary::Detail,SysModule::Ledger,_VoucherCode);
_LedgerVoucherObject = LedgerVoucherObject::newVoucher(_NumberSeq.voucher());
_ LedgerVoucher.addVoucher(_LedgerVoucherObject);
_LedgerVoucherTransObject = LedgerVoucherTransObject::newCreateTrans(_LedgerVoucherObject, LedgerPostingType::LedgerJournal,_Account,_Dimension,CompanyInfo::standardCurrency(), _AmountCur,0,0);
_LedgerVoucherTransObject.parmTransTxt("Arijit Basu");
_LedgerVoucher.addTrans(_LedgerVoucherTransObject);
_LedgerVoucherTransObject = LedgerVoucherTransObject::newCreateTrans(_LedgerVoucherObject, LedgerPostingType::LedgerJournal, _OffsetAccount,_Dimension,CompanyInfo::standardCurrency(),_AmountCur*-1,0,0);
_LedgerVoucherTransObject.parmTransTxt("Arijit Basu");
_LedgerVoucher.addTrans(_LedgerVoucherTransObject);
_LedgerVoucher.end(); ttscommit;
}

2. In Second method

The tables used are LedgerJournalName, LedgerJournalTable, and LedgerJournalTrans. The steps are:
• Create a journal table record {Table\LedgerJournalTable}
• Create lines for each transaction to be posted {Table\LedgerJournalTrans}.
• Post the journal. {Classes\LedgerJournalCheckPost}
Sample Code:
static void LedgerJournalCheckPostDemo(Args _args)
{
LedgerJournalTable _LedgerJournalTable; LedgerJournalTrans _LedgerJournalTrans;
LedgerJournalCheckPost _LedgerJournalCheckPost;// it is the class
NumberSeq _NumberSeq;

ttsbegin;
//----Journal Header
_LedgerJournalTable.JournalName = 'Day1';
_LedgerJournalTable.initFromLedgerJournalName();
_LedgerJournalTable.Name = 'Daily Journal';
_LedgerJournalTable.insert();
//----Journal Line
_NumberSeq
=NumberSeq::newGetVoucherFromCode(LedgerJournalName::find(_LedgerJournalTable.JournalName).V
oucherSeries);
_LedgerJournalTrans.Voucher =_NumberSeq.voucher();
_LedgerJournalTrans.JournalNum =_LedgerJournalTable.JournalNum;
_LedgerJournalTrans.CurrencyCode =CompanyInfo::standardCurrency();
_LedgerJournalTrans.ExchRate =Currency::exchRate(_LedgerJournalTrans.CurrencyCode);
_LedgerJournalTrans.AccountNum ='110180';
_LedgerJournalTrans.AmountCurDebit =1000;
_LedgerJournalTrans.TransDate =Today();
_LedgerJournalTrans.OffsetAccount ='140270';
_LedgerJournalTrans.Txt ='Arijit Basu :)';
_LedgerJournalTrans.insert();
//----Journal Posting
_LedgerJournalCheckPost
=LedgerJournalCheckPost::newLedgerJournalTable(_LedgerJournalTable,NoYes::Yes);
_LedgerJournalCheckPost.run();
ttscommit;
Info(StrFmt("Journal %1 is posted",_LedgerJournalTable.JournalNum));
}


19. How to send email via X++ code?
http://daxguy.blogspot.com/2006/11/send-e-mail-from-axapta.html Sysmailer class used to send the email.
Sample Code:
SysMailer mailer = new SysMailer();
mailer.body("My Body :)"); mailer.subject("WOW Baby");
mailer.fromAddress("Pam@anderson.com");
mailer.fromName("Peter Villadsen");
mailer.tos().add("arijit.basu@gmail.com");
mailer.SMTPRelayServers().add("MyRelayServer");
mailer.sendMail();

20. How exception handling is done in Ax?
An exception is a regulated jump away from the regular sequence of program instruction execution. The instruction at which program execution resumes is determined by try - catch blocks and the type of exception that is thrown. In X++, an exception is represented by a value of the enum named Exception. A frequently thrown exception is Exception::error enumeration value. This exception is thrown in a variety of situations. It is common practice to write diagnostic information to the Infolog before throwing the exception, and the Global::error method is often the best way to do that. You use the following X++ statements to generate and handle exceptions: throw try catch retry

21. How to run stored procedure from Axapta?
We can run or call stored procedure from Axapta.

static void storedProcedure(Args _args)
{
LogInProperty Lp = new LogInProperty(); OdbcConnection myConnection;
Statement myStatement;
ResultSet myResult;
;

LP.setServer("SeverName"); LP.setDatabase("DataBaseName"); Lp.setUsername("sa"); Lp.setPassword("sa");

try
{
myConnection = new OdbcConnection(LP);
}
catch
{
info("Check username/password.");
return;
}

myStatement = myConnection.createStatement();
myResult = myStatement.executeQuery('EXEC [inventtablesp]');//stored procedure name while (myResult.next())
{
print myResult.getString(1);
}
pause;
}


22. How to import code from to another layer?
To move X++ code to another layer while keeping your data:
1. Start Microsoft Dynamics AX in the layer that the X++ code is to be moved from.
2. Use the export command in the Application Object Tree (AOT) shortcut menu to export the X++ code to an .xpo file.
3. Use the export command (Administration > Periodic > data export/import) to export data in the relevant tables. Relevant tables are the tables to be moved to another layer and possibly to other tables with references to the tables you move.
4. Delete the X++ code in the current layer.
5. Click Synchronize on the AOT shortcut menu.
6. Exit Microsoft Dynamics AX.
7. Start Microsoft Dynamics AX in the layer to which you want to move your X++ code.
8. Click Microsoft Dynamics AX menu > Command > Import to import the .xpo file that you created in step 2.
9. Click Synchronize in the AOT shortcut menu to synchronize the tables that you have just created. Now you have the same tables that are in the initial layer, only they have a new Id.
10. Use the import command (Administration > Periodic > data export/import) to import data.
The data import does not use IDs but instead is based on table and field names to identify the data import target. Only users with developer rights can import code in Microsoft Dynamics AX.

23. How will you extend a runbase framework class to include dynamic AOT query?
We can use RunbaseReportStd class to extend it to our report. It will open a dialog box where we can give the input(based on ranges specified in the report datasource) to the report.

24. What is RunBase Framework?
The RunBase framework provides a standardized approach to creating processes and batch jobs in Microsoft Dynamics AX. The framework must be used for every job-style function in the application.
The framework is implemented by the RunBase application class and supplies many features, which include the following: Query Dialog, with persistence of the last values entered by the user Validate Batch execution for users to schedule jobs. This functionality uses the RunBaseBatch class) and the pack and unpack methods with versioning. Progress bar Run Client/server-optimized

25. What are table used in the ledger journal posting?
LedgerTable LedgerJournalTable LedgerJOurnalTrans.
LedgerJournalCheckPost – class is used to check the posting
_LedgerJournalCheckPost =LedgerJournalCheckPost::newLedgerJournalTable (_LedgerJournalTable,NoYes::Yes); _LedgerJournalCheckPost.run();

26. What are methods changed during number sequence creation for new module?
LoadModule() ModuleList() Construct()

27. What is Int64?
It is a 64 bit integer, ex field: recid.

28. What is the use of Arg class?
The Args class is used to pass arguments to a class-constructor. Args can pass information such as name, caller, and parameters to a new class.

29. Use of main ()?
A main method is a class method that is executed directly from a menu option. static void main (Args _args) { ... }

30. What is static ()?
Static methods, or class methods, belong to a class and are created by using the keyword static. They are called by using the following syntax: ClassName::methodName (); You do not need to instantiate an object before you use static methods. It is not possible to use member variables in a static method.

31. What is an instance method?
Instance methods, or object methods, are embedded in each object that is created from the class. They are called by using the following syntax: objectHandleName.methodName (); You must instantiate the object before you can use the method.
Forms
The form is used to support the interaction between the user and the database. The form has focus on displaying and receiving data, filtering, sorting and synchronizing. The form consists of three main components in the AOT: • Methods • Data sources • Design
Methods
The general, methods, which are inherited from the kernel class FormRun, are used to control the start up and shut down of the form. These events are often overridden to make initialization of the form.
Data Sources
The Data source(s) define the interface between the form and the database. An entry is added for each table. The properties of the individual data sources determine the relationship between the data sources. This includes definition of synchronizing and joining. The object for each data source is inherited from the kernel class FormDataSource and has methods related to displaying, validating, and updating data. The methods can be overridden in the individual form, but the general rules should be applied on the corresponding methods on the table. The data source lists all fields in the table. You can adjust properties regarding access on this level, which will apply to all instances of the field on the design. The object for each field is inherited from the kernel class FormDataObject and has methods related to field specific navigation (filter, lookup, jump to main table etc.), validating and modifying the field.
Design
The design of the form defines the interface between the form and the user and controls the layout and presentation of the data. The design is comprised of components called controls. Some controls are used to edit and displaying data, while others are used to control the layout of the form. Handles to the Objects in a Form All methods in the form are related to an object. This object can be accessed by using the handle "this". But you should note this reference is relative to where you are programming. Most of the objects can be accessed with an absolute reference, which can be used anywhere in the form. The following table lists the objects and how you can access them: Object Access from X++
FormRun
Element
FormDataSource
<name of datasource>_DS
Active record in data source
<name of datasource>
FormDataObject
FormDataSource.Object(<fielded>)
FormDesign
FormRun.design()
Form……Control
Name assigned to control, when property AutoDeclaration is set to Yes. or element.control(Control::<name of control>)
Query
<name of datasource>_Q or FormDataSource.Query()
QueryRun
<name of datasource>_QR or FormDataSource.QueryRun()
The method control() on the element object can be used if the control is included in an auto field group. In this situation it is not possible to use the autodeclaration feature. Top Ten Methods to Use
FormRun.Init
This method initializes the form and its objects. This method is the first event you can override in connection with the start up of the form. Never remove the super() call from this method, as this removes the initialization of all the objects. If you want to make some manual initializations this is typically placed in this method. This could include the following tasks: • Verification of the contents of the args-object received • Initialization of supporting classes • Dynamically changes to the design If your manipulation needs access to the objects of the form wait until the super() call has executed.
FormRun.Close
This method shuts down the form. If you have some cleanup in connection with finishing the execution of the form, it will be the place.
FormDataSource.Init
This method initializes the data source and is called from the super() of FormRun.Init(). The method will only be called once when the form is opened. The main task for this method is to initialize the query used for fetching data. If you want to modify or replace the query automatically created by the form, this should be done after the super() call of this method.
FormDataSource.InitValue
This method is used to initialize a new record with default values. The super() of this method calls the corresponding method on the underlying table, which in turn invokes the record template functionality. If you have some initialization which should apply system wide, you should place the code on the table.
FormDataSource.Active
This event is called when a new record becomes active in the data source. This method is typically overridden to change properties which depend on the contents of the current record: • Modify access rights to the data source • Modify access rights to the fields • Enable/Disable buttons
FormDataSource.LinkActive
This method is the engine in connection with synchronizing data sources. This method is called on the controlled data source each time the active record in the controlling data source is changed, if the link type is delayed or active. The method is also called once, when the form is opened even if the link type is passive.
If you dynamically want to remove the active/delayed synchronizing you can make a condition on the call of super() in this method. If you want to control the synchronizing yourself you can remove the call of super() and make a call to FormDataSource.executeQuery().
FormDataSource.ValidateWrite
This method makes the validation in connection with an insert or update of a record. The super() of this method calls the corresponding method on the underlying table. If you have some initialization which should apply system wide, you should place the code on the table. If you must distinguish between an insert and update you can make a condition on the RecId field, which only has a value (be true) if it is an update.
FormDataSource.Write
This method controls the insert and update of records. If you want system-wide follow-updates on these events you should implement these on the table. If you have some form specific tasks to perform in relation to the commitment of the record, this is the place to do it.
FormDataObject.Modified
This method is used in connection with the user changing the contents of the field. This event can be used to make calculations etc. which is dependent on the field. If you want system-wide functionality in connection with a manual change of a database field, you should implement this by overriding the modifiedField method on the table.
FormDataObject.Validate
This method is used to validate the contents of the field. This event can be used to supplement or remove the normal validation. If you want system wide functionality in connection with the validation of a database field, you should implement this by overriding the validateField method on the table.
Using the Infolog system
The Infolog system is a dialog system that displays information, warning, and error messages. The Infolog is updated on screen just before user input is accepted. Add your own information using: info(), warning(), error(), setprefix(), and checkFailed().

32. Define Forms in Ax?
Forms are used to interact with user .It is under AOT node .Contains methods ,datasource ,designs.

33. What is a Wizard?
Ans. A wizard is a special form of user assistance that automates a task through a dialog with the user. Wizards help the user accomplish tasks that can be complex and require experience. Wizards can automate almost any task, such as creating a new report, facilitating data import, or defining access rights. They are especially useful for complex or infrequent tasks that the user may have difficulty learning or doing, or for tiresome, frequently performed tasks. A wizard is a series of presentations or pages that guides the user through a task. The pages include controls that you define to gather input from the user; that input is then used to complete the task for the user.

34. Which class can Wizard extends?
Ans. Depending on the type of wizard you chose, your wizard class extends either the SysWizard class, or the SysBaseDataWizard.
35. List the application objects which are automatically generated by the Wizard wizard.
1.Project containing the Appl objecst. 2. A Class 3. A form 4. A display MenuItem

36. Does Cross-Reference update Form Methods?
i. No

37. What are the sequence of classes or methods on forms?
Ans:- new constructor of the form Init method of the form Init method of the form datasource. Run method of the form ExecuteQuery method of the form datasource. Firstfield method of the form is fired. form classes : Formrun, FormBuildDatasource, Formdatasource, FormBuildDesign,FormDataObject

38. How will you run a batch job form X++?
A batch job is a group of tasks that are submitted to an AOS instance for automatic processing. The tasks in a batch job can run sequentially or simultaneously. In addition, you can create dependencies between tasks. This means that you can set up a different sequence of tasks depending on whether an earlier task succeeds or fails. Implement classes by using the batch processing system, and by extending the RunBase and the RunBaseBatch classes.
It is recommended that you designate a class to run as a server-bound batch job. Server-bound batch jobs are more secure than jobs that are not server-bound batch for the following reasons: The job executes by using the permissions of the user who submitted the job. The job can interact with the Microsoft Dynamics AX client, which is processing the job, by using only certain Info and Global class methods. This limits interaction with the client. Enable a Class to Run as a Server-Bound Batch Job
1. Create a class that extends the RunBaseBatch class.
2. Override the RunBaseBatch.runsImpersonated method to return a value of true, as shown in the following example.
public boolean runsImpersonated() { return true; }
3. Confirm that the class calls only the following Info and Global class methods:
o Info,add
o Info.copy
o Info.cut
o Info.import
o Info.export
o Info.line
o Info.num
o Global::Error
o Global::info
o Global::warning
The Info.line and Info.num methods are inherited from the xInfo class.

39. What is the use of close (), canClose () in form?
canClose () The super () call checks whether it is a valid action to close the form. canClose is activated by closeCancel and by closeOK. Use this method to add your own checks to the system’s close verifications. close () The super () call closes the form window, manages database updates, and sets the Boolean flag closed. Depending on the close state of the form, close is activated either by closeCancel, or by closeOK.

40. Sequence of events called on opening of form
1. new - form object initialized 2. Init - on Form 3. Init - on Datasource 4. Run - on form 5. executeQuery - on datasource 6. FirstField - on Form

41. When do we need to set data for temporary table in Form
During Datasource Init

42. How can u Create a blank record when form popup?
call table_ds.create() on form init

43. How to create form using code?
The Form* classes enable you to manipulate, create, modify, or run forms by using X++ code. You can also modify forms during run time so, for example, one or more controls are hidden on a form, depending on the user's selections in the preceding form.
Create a form by using the FormRun and Form classes, and a variety of other classes that modify the form design and data source. Place the code into a method that is called from a main class method to view the form. The signature of a main method is static void main (Args args). The Form classes are all system classes and are prefixed with Form—for example, FormRun, FormStringControl.
Form
FormRun FormDesign FormBuildDesign FormDataSource FormBuildDataSource FormControl Form<control name>Control For example, FormStringControl, FormTreeControl FormBuild<control name>Control For example, FormBuildStringControl, FormBuildTreeControl The form build classes that contain property methods for an individual control type.

44. Explain Dialogs?
Extend the RunBaseBatch class to implement dialog. A dialog in Microsoft Dynamics AX is a simple form with a standardized layout, created by using the Dialog system class. The dialog should not open a secondary window that requires user interaction. All user interaction should be carried out within the dialog. Use the addField method to add fields to the dialog. The addField method returns objects of the DialogField type. Use the addGroup method to group related fields. Use the addTabPage method to add tabbed pages. Use the value method to set and get values in the dialog. Use the run method to launch the dialog. When the user clicks OK or Cancel, the run method returns true or false, respectively.
Dialog is the main class used to construct dialogs. DialogRunBase is an extension of the Dialog class that is used by the RunBase framework. The DialogControl class defines a single control in the dialog. DialogControl is extended by classes for the following control types: DialogField DialogGroup DialogTabPage DialogText DialogWindow

45. Explain Batch Process?
Dialog is used to get the user input to run the batch. Here we extend the class with RunBaseBatch class. The above dialog process is applied to design the Dialog for batch interface.

46. How to Display a Message Box?
Box class and DialogButton Enum are used for the Message Box. Some methods in the Box class display a dialog box that contains multiple buttons. These methods have a parameter for choosing which button has focus when the dialog box is first displayed. This parameter is of type DialogButton Enum. Most of these multiple-button methods return a value of type DialogButton Enum. This returned value enables your program to branch based on which button the user clicked. info infoOnce okCancel warning yesNoCancel yesNo etc.,
Example: DialogButton diagBut; diagBut = Box::yesNoCancel(strMessage, DialogButton::No, // Initial focus is on the No button. strTitle); if (diagBut == DialogButton::No) { print "The No button was clicked."; }

47. Which kernel class is documenting the individual field in a data source and how do you get a handle for it?
A. The object for each field is inherited from FormDataObject Kernel Class.(P – 127).

48. Which method do you override if you want to make changes to the structure of the query which fetches data to the data source?
A. If we want to modify the query automatically created by the form we should override the FormDataSource Init method.(P – 135)

49. What is the use of AutoQuery property in form’s datasource?
Setting the AutoQuery property on a form data source to Yes causes the system to automatically generate the query that retrieves data to display in the form. The AutoQuery property will fetch the records automatically if you set to yes. If No we should use queryBuildRange class to generate the query Active Query on Forms. Init the queryBuildRange object in init method of datasource after the super (); and specify the value to execute in the ExecuteRange () method.

50. What is Bound Controls, Unbound Controls and Calculated controls?
Bound control – associated with a field in an underlying table. Use bound controls to display, enter, and update values from fields in the database. Unbound control – does not have a data source. Use unbound controls to display pictures and static text. Calculated controls – uses a method as the data source. An example of a calculated control is the sum of two fields on a form.

51. How to link two forms?
Using menuItem or by code we dynamically link two forms. Dynamic Links are based on Extended Data Types. And create the relation between two tables Using menuItem is normal procedure. Using by code we use FormRun class to run the Form.
Ex:- Create a button in new parent form and in the clicked method of that button use these code to call the child form. // The override of the clicked method on the button.

button. void clicked()
{
Args myArgs;
FormRun myFormRun;
;
// Keep this call to super() when overriding the clicked method. super();
myArgs = new Args();

// Provide the name of the form to launch. myArgs.name("BankAccountTrans");

// The BankAccountTable data source variable name
// represents the currently selected item in the grid
// on the parent form (and thus in the data source). myArgs. Record(BankAccountTable);

myFormRun = ClassFactory.formRunClass(myArgs);

myFormRun.init(); myFormRun.run(); myFormRun.wait();
}


52. What are different types of variable used in the form?
Variables usually need to be declared before they can be used. Working with forms, however, some variables are implicitly declared by the system.
Variables to Reference the Entire Form
The system creates the element variable. It is used to reference the entire form object. The element variable is typically used in assignments, such as the following. NotifyDate = element.design().control(control::NotifyDate);
Variables to Reference the Data Source Table
The system creates a variable. Its name is the same as the table's that is used as a data source. This enables you to do the following: Call a method defined on the table used as a data source for the form. For example:
MyTable .setDefault(ReadWrite::write); Reference the individual fields in the table. For example:
AccountNumber = MyTable .accountNo;
Variables to Reference Properties and Methods on the Form Data Source
The system creates a variable. Its name is the same as the table's that is used as a data source, but is postfixed with "ds." This enables you to reference properties and methods on the form data source (as opposed to the table itself), as shown in the following example. MyTable_ds .research(); MyTable_ds .validateWrite();

53. What is the use of Display ()?
Ans. To define a display method, give the display keyword right before the method’s return type, for example: display Amount Amount() which is a method on the CustTrans table. The exception to this is when you define display on a form data source method. If you choose to write a display method on a form data source, you must include the data source as parameter, for example display InventQty Accumulated(InventBudgetInvent Budget) which is a method on the data source for the InventBudgetInvent form. Note You must use display on a form data source method when the return value is to be shown on a grid control The display method modifier is used to indicate that a method's return value is to be displayed on a form or a report. If you want users to edit the value in the control, use an edit method. Use the display modifier on methods in the following: Table methods Form methods Form data source methods Report methods Report design methods
Write your display methods on a table. You can use the same code in several forms or reports.

54. What is the use of Edit ()?
The edit method modifier is used to indicate that a method's return value is to be displayed on a form, and users can edit that value. If you don't want users to edit the value, use a display method.
Use the edit method modifier on the following: Table methods Form methods Form data source methods
Write your edit methods on a table. You can use the same code in several forms.

55. Explain in details about the Lookup Forms?
Some fields on forms enable users to select a value from a different form. These controls are shown with a Lookup button next to them. When the user clicks the arrow, a Lookup form opens. The Lookup form shows possible values for the field and supporting information to help users make the correct choice. There are 3 different ways to create the Lookup forms
1 Lookup forms are based on relations
The contents of Lookup forms are based on relations set up on the database table and/or the extended data type for a field. Lookup forms consist of the following components: TitleField1 from the related table (set by the TitleField1 property) TitleField2 from the related table (set by the TitleField2 property) The fields that make up the relation
The fields shown in a standard lookup form are determined by the relations set on the database table or on the extended data type for the field. The fields shown in the lookup form are those in the relation and those specified for the TitleField1 and TitleField2 properties on the related table.
2 performDBLookup, performTypeLookup and performFormLookup
Override the Lookup method in the form control For Ex: public void lookup() { FormRun formRun; Args args; ; args = new Args("CustTable"); formRun = classFactory::formRunClassOnClient(args); formRun.init (); this.PerformFormLookup (formRun); }
3 Creating Run-Time Lookup Forms
To create a lookup form that displays different fields, override the lookup method on the form control that will display the lookup by using the SysTableLookup application class. When you override the lookup method, comment out the call to super (). Otherwise, an autogenerated lookup form will instead be displayed. Query, QueryBuildRange, QueryBuildDataSource and SysTableLookup classes are used to generate the lookup form Add the fields to be shown in the lookup form sysTableLookup.addLookupField(fieldNum(custTable, accountNum));
Limit the data selection. queryBuildDataSource = query.addDataSource(tableNum(custTable)); queryBuildRange = queryBuildDataSource.addRange(fieldNum(custTable, accountNum)); queryBuildRange.value('A..B'); sysTableLookup.parmQuery(query); Perform the lookup, and delete super(). super() will create an autogenerated lookup form. sysTableLookup.performFormLookup(); // super()

56. Create a new record when the user opens a form
Ans. To create a new record each time the user opens a form Call the create method on the form data source, and Use suitable settings for the data source properties InsertAtEnd (= No) and StartPosition (= First).
An example from
\Forms\PurchCreateOrder\Methods\run
void run()
{
purchTable_ds.create();
element.modifyForm();
super(); // more code lines
}

57. What are the characteristic of a table control?
The Table control looks like a grid. The Grid is predefined with field as columns and records as rows.

58. Which method do you override if you want to make changes to the structure of the query which fetches data to the data source?
A. If we want to modify the query automatically created by the form we should override the FormDataSource Init method

59. Which kernel class is documenting the individual field in a data source and how do you get a handle for it?
A. The object for each field is inherited from FormDataObject Kernel Class.

60. What is pack and unpack()?
Well, basically, the pack method serializes the object, and unpack deserializes it. What this gives you is the ability to automatically have all the variables set to specific values next time the job (class) is run. For example, you have a class that prompts the user for an ItemId and does something with this item. Each time the job is run, the user would have to select the item again, if it were not for the pack/unpack methods. All you have to do to use them is declare the needed variables in the classDeclaration add a macro defining the CurrentVersion of the parameterList and implement the pack and unpack methods. (The code is in the RunBase class - just copy it (removing #if.never, of course)Please note that the information that is saved /
restored is per user & per company basis.The important thing to remember is - version id. If you change the contents of container, you should remember to increment the version id.

61. What is the use of Titledatasource in form?
Specify the TitleField1 and TitleField2 property in the table and select the table corresponding table name in Titledatasource property in the design node of the form.

62. What are types of join in form?
Setting How the join is performed

Passive Linked child data sources are not updated automatically. Updates of the child data source must be programmed on the active method of the master data source.

Delayed A pause is inserted before linked child data sources are updated. This enables faster navigation in the parent data source because the records from child data sources are not updated immediately. For example, the user could be scrolling past several orders without immediately seeing each order lines.

Active The child data source is updated immediately when a new record in the parent data source is selected. Continuous updates consume lots of resources.

InnerJoin Selects records from the main table that have matching records in the joined table and vice versa. There is one record for each match. Records without related records in the other data source are eliminated from the result.

OuterJoin Selects records from the main table whether they have matching records in the joined table. Selects all record from main table and only matching records in joined table.

ExistJoin Selects a record from the main table for each matching record in the joined table. The differences between InnerJoin and ExistJoin are as follows: When the join type is ExistJoin, the search ends after the first match has been found. When the join type is InnerJoin, all matching records are searched for.

NotExistJoin Select records from the main table that do not have a match in the joined table.


Form Level Methods





63. Define Reports in Ax?
Ans. Reports are used to get printed overview of information extracted from your application’s data.It is under AOT node.Conatains methods, datasource query, datasource,design, report design.

64. What is the use of Fetch method? Override the fetch method to filter the data displayed in a report. This override does not reduce the number of records that are returned by the report's query. Instead it prevents some records from being sent to the final report. Each record is examined by the branching logic you put in the fetch method. Branching determines which records to give to the send method.

65. What is the difference between Generated Design and Auto design specs? Auto design specs
When using a design specification, MorphX creates the layout of the report when the report is run. The layout is based on the structure of the query specified below the report’s Data Sources node. Generated Design
When you create a customized design, MorphX takes a snapshot of the current state of the design specification. This snapshot is placed below a Design node in the report. A customized design allows the programmer to control all aspects of the layout of the report. Under the body node, a PageHeader node that you can customize appears when you use the generated mode. This PageHeader node does not appear when you use the automatic mode.

66. What is the most important difference between reports built with auto design and generated design?
A. AutoDesign System developer can’t control the layout of the report as it is generatd at Runtime. Generated Design: The Report will be presented as specified and implemented by System Developer.

67. Which method do you override, if you want to select data from the database using while select
A. Fetch method

68. What is the purpose of the RunBaseReportStd framework?
1.To make a one step dialog with both dialog fields, Query ranges and printer selections visible. 2.To make it possible to batch execute a Query.

69. What are ad-hoc reports.
Ans. When an existing report does not provide the information a business user wants to see, the user can create a report on-demand or for a specific purpose. This is called an ad-hoc report. An upcoming release of Axapta will work with SQL Server 2005 Reporting Services Report Builder, a powerful ad-hoc reporting tool. By using this tool, business users can create reports by dragging and-dropping. Users interact with a user-friendly model of the business data. Users can create powerful and flexible reports without having to understand a complex query language, even if the information spans many modules.

70. When should you consider using temporary tables in a report?
AWhen the data in a Report is from Multiple tables,It is difficult to structure the Query In such cases we use Temporary Tables.

71. Which method would you use to initialize printjobsettings for a specific report, when this report is called from a class?
A. ReportRun.UnpackPrinterSettings ()retrieves the printer option for the report.

72. What is Queryform?
The report uses a query to retrieve the information you want to present in the report from the database. The QueryForm is a form that is run before the report is executed. This is how the report interacts with the user at run time.

73. Which method is used to retrieve the records from table in report?
Fetch () Here we can get () and next () Send () is used to the each record to report.

74. Explain the sections the in reports?

Database
FETCH OF DATA
Query
Query
A query is an object-oriented interface to the SQL database. A query is composed of objects from different classes.

The queryRun object is used to execute the query and fetch the data, while the query and the rest of the objects are the blueprint of the SQL statement.

The query object is the master of the definition. It holds some properties itself and has one or more related data sources.

The queryBuildDataSource defines access to a single table in the query. If more data sources are added to a query
at the same level, they result in separate SQL statements which are executed sequentially. If one data source is added below another data source they form a join between the two tables.

The queryBuildFieldList object defines which fields to fetch from the database. The queryBuildRange object contains a limitation of the query on a single field.
The queryBuildDynaLink objects can only exist on the outer data source of a query. The objects contain information regarding a relation (limitation) to an external record.

The queryBuildLink objects can only exists on inner data sources. The objects specify the relation between the two tables in the join.


Accessing fields in tables


In Axapta tables, fields are always public; that is, they can always be accessed directly. To access the fields you do not have to write accessor methods, but sometimes you will do it anyway to simulate protectin g the fields, and give yourself an option to later modify how to get and set the value of the field.

Working with more than one company
Large companies are often split up into several legal entities. MorphX supports this by using the changecompany function in X++.

changecompany
The change company statement is used to alter the database settings to another (separate) company. The syntax of the statement is:

Changecompany = changecompany ( expression ) Statement

The expression is a string expression, which defines which company is to be used. The statement is executed on the new company.


75. What is the use of Delete and doDelete methods?
Delete Method: Deletes the selected record in the table.
DoDelete Table Method Deletes the current record from the database.
Use the doDelete method if the delete table method has been overridden, and you want to use the original version of the delete method. The doDelete method executes the base version of the delete method instead of the overridden version—it is equivalent to executing super () in the delete method. If delete method is overridden we can use doDelete () to delete record without executing the delete () code.

76. What is Synchronize command in the AOT shortcut menu?
Ans. synchronize the database with the SQL database.Whenever global changes to the data dictionary occur, you have to synchronize the SQL database as well. Global changes are changes that are not specific for a given table, such as the Extended Data Types, or Feature Keys.

77. Define Queries and jobs?
Queries
Queries are used as the source of records for forms and reports. Use the Queries node to: Define which database tables you want to see data from Define X++ functions to manipulate the data.
Jobs
The Jobs node typically holds small X++ programs that are often executed as batch jobs.

78. Define DD and Macros?
Data Dictionary
Use the Data Dictionary node to set up the data types and tables that make up your database. To define a database: Define the data types you plan to use in your set of tables Set up each table in your database with fields, indexes and object methods.
Macros
A macro is a code or text substitution that cannot run independently, but can be used anywhere you can write code in the system, for example in jobs, classes and forms. The Macros node holds the macros used by the standard application. Besides viewing the existing code you can add your own macros.

79. Record Id Generation is Managed by whick Table
a. SystemSequence Table

80. How many bytes memory taken by RecId in 3.0 and 4.0?
Ans. AX3.0 – 32 Bytes AX4.0 – 64 Bytes

81. What is the new data type included in 4.0?
Ans. Int64 and GUID data type are added

82. How many record Id are reserved to each client session
25

83. Use of Definition Group
a. A definition group is used as a filter for an import

84. When would you use RecordInsertList?
To increase the performance when significant data is involved. When we require a subset of data from a particular table, that need to be sorted in an order that does not exist currently as an index.

85. How to move tables to another layer?
Tables in Microsoft Dynamics AX are identified by their application object ID number series. Different ranges of IDs are used for different application object layers. For example, IDs in the range 1-20000 are used for SYS layer objects, whereas objects in the VAR layer use IDs in the range 30001-40000. This is important if you want to move tables and the data in the tables from one layer to another, for example, from the VAR to the CUS layer. This procedure describes how to move a table, together with data, to another layer. Procedures To move a table to another layer
1. Start Microsoft Dynamics AX in the application object layer that the source tables are located in.
2. Export the data from the tables that you want to move. For more information, see How to: Export Objects from a Selected Layer.
1. Export the tables that you want to move to an .xpo file. For more information, see How to: Export Application Objects.
2. In the Application Object Tree (AOT), delete the tables that you want to move.
3. Exit Microsoft Dynamics AX.
4. Restart Microsoft Dynamics AX in the layer that you want to move the tables to.
5. Import the tables from the .xpo file that you created in step 3. For more information, see How to: Import Application Objects.
6. In the AOT, right-click the Data Dictionary node, and then click Synchronize to synchronize the database with the imported tables.
7. Import the data from the location that you exported the data to in step 2. For more information, see how to: Add Data. The data is added to the tables with the new application object IDs allocated for the destination layer.
Note :
Select Field type Binary in the Export options dialog box to preserve container fields and increase performance.

86. What is DeleteAction?
The DeleteAction element helps maintain database consistency when a record is deleted. Define delete actions to specify what should occur when data being deleted in the current table is related to data in another table.


In restricted delete action if try to delete through x++ code record in parent table will get deleted but not in the child. So we should call validateDelete () before Delete ().

Cascade+Restricted

The delete action performs a restricted, if the record of the table will be deleted directly and performs an cascade, if the record of the table will be deleted through a cascade delete action of a other table. e.g.:
tableA (Customer) (a cascade deleteaction to tableB) tableB (SalesOrder) (a cascade+restricted deleteaction to tableC) tableC (SalesLine)
When a record of tableB will be deleted, the restricted part of the deleteaction will be performed. The
record of tableB can only be deleted, if no record in tableC exists for the record in tableB. (The SalesOrder can only be deleted, if no SalesLine exist for the SalesOrder).
A record in tableA will be deleted, so the cascade deleteaction to tableB will be performed. In this case, the cascade part of the deleteaction to tableC will be performed. (When a Customer will be deleted, the SalesOrders and SalesLines will also be deleted)


87. How we can join data source to another data source?And which property we will use?
Ans. The property used to define the type of join is called LinkType. To join a child data source to a master data source, set the JoinSource property to the master dataset and the LinkType to InnerJoin, OuterJoin, ExistJoin, or NotExistJoin.

88. In which table delete action will be specified?
In the parent table delete action specified.

89. What is RecID?
The RecId is a unique field in every table, used as an identifier. Every row in the system can be guaranteed (in theory) to have a unique RecId. RecIds can be negative, and their value can change due import/export operations. Due to this, it is not a good idea to use RecIds as foreign key references to other tables.
If RecId corruption occurs, the SysRecIdRepair can be used to correct the problems. Axapta uses SystemSequences table to store current value of RecID

90. Where relation will be specified?
Table relations are most commonly used in form fields to enable the look up of information in another table. If a table relation exists, the lookup button can be used to display a lookup list of values for a particular field. Where we need relation there we create relation on the table. There is no constraint. Use the Validate property to decide if the relation should be used to validate data when entering information in forms.

91. What is the difference between EDT Relation and Table Relation?
In Table Relation
o Keep the database consistent (enforce referential integrity).
o Enable the look up of values in other tables
o Are used to validate data.
Table relations are most commonly used in form fields to enable the look up of information in another table. If a table relation exists, the lookup button can be used to display a lookup list of values for a particular field. In EDT Relation You can use relations on extended data types to create a relationship between fields in different tables. The relationships you define on an extended data type are automatically inherited by tables that contain fields based on this extended data type.

92. What will happen when u insert thru Sql server directly for a ax table?
It will get inserted and able to look that record in Ax table. But RecID and DataAreaID should insert manually.

93. How to optimize record insert?
You can use RecordSortedList or RecordInsertList to hold your rows until they are inserted. Both classes have an insertDatabase method that is used to insert the records into the database as efficiently as possible. However, the insertDatabase method does not empty the list itself.You can also use insert_recordset to insert multiple rows on a single server trip. It is faster than an array insert, but limited to simple manipulations that can be implemented as SQL expressions. Array inserts enable you to perform more manipulation on the data before it is inserted.

94. Temporary Tables vs. Containers?
Microsoft Dynamics AX supports a special data type called a container. This data type can be used just as you would use a temporary table. For more information, see Containers.
Data in containers are stored and retrieved sequentially, but a temporary table enables you to define indexes to speed up data retrieval. Containers provide slower data access if you are working with many records. However, if you are working with only a few records, use a container. Another important difference between temporary tables and containers is how they are used in method calls. When you pass a temporary table into a method call, it is passed by reference. Containers are passed by value. When a variable is passed by reference, only a pointer to the object is passed into the method. When a variable is passed by value, a new copy of the variable is passed into the method. If the computer has a limited amount of memory, it might start swapping memory to disk, slowing down application execution. When you pass a variable into a method, a temporary table may provide better performance than a container.

95. Explain View? View is like a query. It creates an object in the Sql server. A Microsoft Dynamics AX view is a virtual table that contains the data records and fields that are specified by a query. Views are Read only. We cannot insert or delete the record. No index in view. A view uses a query to retrieve data fields from one or more database tables. In Microsoft Dynamics AX, you can use views where you use tables. For example, you can use a view in a form, a report, and in X++ code.
Benefits:
i. Focused Data
ii. Customized Data
iii. Performance

96. What is configuration key and security key?
Configuration Keys: Allows administrators to enable or disable features in the application for all users. Security Keys: Allows administrators to set security on a user group level.

97. What is Definition group?
Definition group defines one definition that contains what are tables needed to export, where the export file should be stored. Administration -> Periodic -> Data Import / Export -> Definition groups

98. Explain the caching in Axapta?
Microsoft Dynamics AX database record caching is a performance-enhancing feature that helps avoid database access when it's not strictly necessary. Retrieving database records from memory instead of the database significantly speeds up data access. Caching can reduce the performance penalty for repetitively accessing the same database records. Types of Caching
1. Single-record
Defined at design time Moves records to the cache based on the table's CacheLookup property and the type of SELECT statement that is used to retrieve the record
The table's Primary Index property is set to a unique index that exists on the table. The RecId index does not qualify as a caching index unless you set the table's Primary Index property to this index. The fields in the table's unique index make up the caching key. The SELECT statement that selects the records uses an equal operator (==) on the caching key. The fields in the WHERE clause of the SELECT statement match the fields in the index referenced by the table's Primary Index property. NotInTTS - No caches made outside the transaction are used. When inside a transaction, the record is read once from database and subsequently from cache. Found FoundAndEmpty EntireTable
2. Set-based
Defined either at design time or in X++ code Moves sets of records to the cache At design time, by setting the table's CacheLookup property to EntireTable. Implemented either through the table's CacheLookup property or in code by using the RecordViewCache class

99. Explain Maps?
Maps define X++ elements that wrap table objects at run time. With a map, you associate a map field with a field in one or more tables. This enables you to use the same field name to access fields with different names in different tables. A table can be accessed through more than one map. Typically, if more than one map accesses the same table, each map accesses different subsets of fields in the table. Maps don't define database objects and so they aren't synchronized with the database. We have index in map.
The benefits of maps include: Simplicity - maps provide a single interface to fields in multiple tables. This means that any object referencing the map field can be used against multiple tables without changing any field names. Consistency - table fields with varying names can be accessed in code in a consistent manner. For example by using a map, fields named Zip in one table, ZipCode in another, and PostalCode in yet another table can all be accessed by the name ZipCode. Code reuse - a map method enables you to add code that runs against the map fields. A single map method prevents the duplication of methods and code on each table.

100. Explain Record level security?
Record level security (RLS) is automatically handled by the kernel when a form or report is opened. RLS is created using Administration Area -> Security -> Record Level Security. However, record level security is bypassed in the following situations: Using display and edit methods Using FormListControl, FormTreeControl or TableListControl to show data Using a temporary table as a data source

101. What is EDT?
Ans. Extended Data type : Extended Data Types are data types defined by the application programmer. An Extended Data Type is based on one of the primitive data types (or another Extended Data Type), but one or more properties have been modified to reflect a real world domain more accurately. Once this Extended Data Type has been defined, it is globally available in you application.

102. What is the advantage of using EDT?
The advantages of extended data types are as follows: Code is easier to read because variables have a meaningful data type. For example, Name instead of string. The properties you set for an extended data type are used by all instances of that type, which reduces work and promotes consistency. For example, account numbers (AccountNum data type) have the same properties throughout the system. You can create hierarchies of extended data types, inheriting the properties that are appropriate from the parent and changing the other properties. For example, the ItemCode data type is used as the basis for the MarkupItemCode and PriceDiscItemCode data types.

103. How EDT relation works?
EDT relation works as Lookup in the table and form where we extended that EDT to specific field.

104. What it the purpose of using temporary tables in Reports? How to use?
Temporary tables are used for non-persistent storage in Microsoft Axapta. They are useful in two common situations
1. As the datasource for a form or report, where the original data is too complex to be easily queried.
2. As temporary storage during complicated processing, to hold the results midway through the process.
Temporary Table data is populated only in the static methods only. If u use other non static methods data couldn’t populate.
Temporary tables in forms
setTmpData(call the static method) method is used to populated the data.// Sample code: public void init() { super(); TempTable.setTmpData(tmpTableClass::populateTmpData()); } It is also possible to add a table to a form which is not a temporary table, but the data that is shown must be temporary. public void init() { super(); InventTable.setTmp(); InventTable.setTmpData(InventTableClass::populateTmpData()); }
Temporary tables in reports
Here setRecord() method is used in reports instead of setTmpDate()
public boolean fetch() { boolean ret; ; this.queryRun().setRecord(tmpTableClass::populateTmpData()); ret = super(); return ret; }

105. Explain Query?
Queries enable you to ask questions about the data in the Microsoft Dynamics AX database and retrieve information. There are two ways to create queries: Use the Queries node in the Application Object Tree (AOT) to create static queries using a graphical interface. Use the query system classes to create dynamic queries in code.
A query can be data source to table, map, or view.

106. How to create the cross company query?
A cross-company query returns data for several companies in a single run. A query does not have to be limited to returning data for the current session company. A cross-company query operates over all companies that you have read permissions for, or over a subset of companies that you specify. To create a cross-company query: In X++, use the crossCompany keyword on the X++ select statement. In X++, set the allowCrossCompany property method to true on an instance of the Query class. In the AOT, set the AllowCrossCompany property to Yes on a node under Query.
Cross-Company Querying in Forms
You can also design cross-company query behavior into dynamically linked parent and child form pairs. One important step in creating such forms is to set the FormDataSource .crossCompanyAutoQuery to true. Or in the AOT, set the CrossCompanyAutoQuery property to Yes on a node under the Data Sources of a Form. while select crossCompany minof( ratingNum ) , dataAreaId from tab21a group by dataAreaId { changeCompany( tab21a .dataAreaId ) { tab21b = null; delete_from tab21b where tab21b .ratingNum == tab21a .ratingNum; } }

107. How to create Query using X++ Code?
public void myQuery2() { Query q; QueryRun qr; QueryBuildDataSource qbd; QueryBuildRange qbr; q = new Query(); qbd = q.addDataSource(TableNum(CustTable)); qbr = qbd.addRange(FieldNum(CustTable, AccountNum)); qbr.value('4005'); qbd.addSortField(FieldNum(CustTable, Name));
qr = new QueryRun(q); qr.prompt(); pause; }

108. What keyword is used for more than one select?
delete_from insert_recordset update_recordset

109. What is index and explain?
An index is a table-specific database structure that speeds the retrieval of rows from a table. Indexes are used to improve the performance of data retrieval and to ensure the existence of unique records. It's up to the database-specific query optimizer to use available indexes to facilitate efficient data retrieval. Indexes are synchronized with the database. A field of data type memo or container cannot be used in an index. There are two types of indexes: unique non-unique.
Whether an index is unique is defined by the index's AllowDuplicates property. When this property is set to No, a unique index is created. The database uses the unique index to ensure that no duplicate key values occur. The database prevents you from inserting records with duplicate key values by rejecting the insert System Index Microsoft Dynamics AX requires a unique index on each table so if there are no indexes on a table or all the indexes are disabled, a system index is automatically created. The system index is created on the RecId and DataAreaId fields if the DataAreaId field exists. Otherwise the system index is created on the RecId field.

110. How to maintain the Data Integrity?
You can maintain database integrity by using one or more of the following features:

  A DeleteAction element maintains database consistency when a record is deleted. For more information about adding a DeleteAction element, see How to: Create Delete Actions.
Note
If you add a DeleteAction to a table and you use the delete_from statement, database performance will be slow. For more information, see  delete_from.

     The forUpdate keyword in a select statement and the selectForUpdate table method ensure that records must be selected before they are updated or deleted. For more information, see  Select Statement Syntax.
     The ttsbegin, ttscommit, and ttsabort keywords ensure that all changes that are associated with a transaction are completed successfully. If the changes are not successfully completed, the transaction is aborted and the database is rolled back to the initial state.

   
Table level Methods


111. Define WebForms?
Web Forms
Using the Web Forms node, design the dialogs that are the user’s Web interface to the database.

112. How to use the .NET business connector?
http://daxguy.blogspot.com/2007/05/dax-401-net-business-connector.html Example:
http://blogs.msdn.com/cesardelatorre/archive/2007/07/06/accessing-dynamics-ax-4-0-from-net-using-the-dynamics-ax-net-business-connector.aspx The Business Connector is a Microsoft Dynamics AX 4.0 component that enables external applications to interact with Application Object Server instances. Microsoft.Dynamics.BusinessConnectorNet Microsoft Dynamics AX 4.0 now includes two versions of the Business Connector; a COM version, and the new .NET version.The .NET Business Connector provides a set of managed classes that provide easy access to X++ functionality in Microsoft Dynamics AX 4.0. It is installed with and used to support the functionality in the EP server, Reporting server,and Application integration server roles. The .NET Business Connector can be installed as a stand-alone component, and used to develop third-party applications that integrate with Microsoft Dynamics AX 4.0. The .NET Business Connector consists of 3 layers: •Managed classes: Exposes public methods that can be called to interact with Microsoft Dynamics AX 4.0. •Transition layer: Maps the managed classes to the corresponding interpreter functions. •Interpreter layer: Executes X++ and communicates with the Application Object Server.

113. To instantiate an instance of a Microsoft Word COM object, you would use the following line:
wordAppl = new COM(“ “); A.COM wordAppl ; wordAppl = new COM(―word.Application‖);

114. What must be registered for external applications to access Microsoft Axapta’s business logic?
A.Microsoft Axapta Business Connector must be Registered for external applications to access Microsoft Axapta’s Business logic The other Appl can use Axapta as a COM object.

115. What is the best resource to use to find more information on accessing Microsoft Outlook through a COM object?
A. With ― outlook. application‖ COM object we can access a large amount of functionality

116. What happens if you call a method that does not exist on the COM object ?
A.If we call a method that does not exist on the COM object we get
― Error Executon code: COM object does not have this method.

117. Explain the Enterprise portal?
Enterprise Portal provides a Web-based application framework that allows for users to interact with data in Microsoft Dynamics AX through a Web browser. You can create new content for Enterprise Portal, and also modify existing content. Most additions and changes can be made using resources in the Application Object Tree (AOT) in combination with Windows SharePoint Services. More advanced applications and modifications can be created by using Visual Studio and the development framework for Enterprise Portal.

118. How to Install an Enterprise Portal server?
Install the Business Connector, create business connector proxy user in the Active Directory. And add the proxy account to IIS and Windows SharePoint Services local Windows groups.

119. How to configure the Windows Share Point Services?
You can download Windows SharePoint Services from Microsoft.com. SharePoint technologies can be installed with MSDE, Microsoft SQL Server 2000 with SP4, or Microsoft SQL Server 2005. To configure an existing installation of Windows SharePoint Services, use SharePoint Central Administration, available from Start > All Programs > Administrative tools > SharePoint Central Administration.

120. What are EP development techniques?
1. Windows SharePoint services Most of the basic development and customization tasks for Enterprise Portal are performed using the Web-based development tools in Windows SharePoint Services. Tasks like creating new pages or adding Web parts to existing pages are all performed directly in Windows SharePoint Services. Enterprise Portal can be used with Windows SharePoint Services or with Microsoft Office SharePoint Server. 2. AOT The resources for Enterprise Portal are stored in the AOT. Some development tasks are performed directly in the AOT, such as defining data sets, business logic, security, site structure, and navigation for Enterprise Portal.
3. Visual Studio
The content of several Web parts in Enterprise Portal is developed by using the Enterprise Portal framework and Visual Studio. You can use this framework and Visual Studio to customize existing controls for Enterprise Portal. You can also create new controls. The most sophisticated functionality of Enterprise Portal is created by using Visual Studio.

AOS
1. Explain the AOS? In Microsoft Dynamics AX, there is a 3-tier infrastructure with a database server, an application object server (AOS), and a client. The database server contains the table data. The AOS is used to execute application objects, such as queries and classes. Application objects in the user interface, such as forms and reports, run on the client computer.
Since every database operation goes through the AOS, if your code does more than one operation on the database, it should run on the AOS. If your code has more than one call to the AOS, it should run on the AOS.

2. What is Application Object RunOn Property?
a. Class By default, class and table static methods run in the same location as the class object. To modify the default setting, you can add client or server, or both, to the class static method declaration. Classes that extend or inherit from another class also inherit the RunOn property. If the inherited RunOn property value is set to Client or Server, it cannot be modified. If the inherited RunOn property is set to Called from, it can be modified in the property settings for the class.
1. Classes have a property called RunOn with the following values: Client Called from (default setting) - Called from can run from either the client or server, depending on where the object is called from Server
2. Or we can specify by code to run the method in client or server or called from
// AOSRunMode::server. Public static server void main (Args args) { // ToDo Add method code here. } // Sets the RunOn property to Called from. Client server static boolean myMethod () { // ToDo Insert code here. } // Sets the RunOn property to Client. Client static boolean myMethod () { // ToDo Insert code here. }
b. Form
Form RunOn property is Client
c. Report
Report RunOn property is Called from
d. Table
Table RunOn property is Called from

3. Explain the Batch job?
You can design your own batch job by extending the RunBaseBatch class. You can also write code to schedule the batch to run. By default, after a batch is scheduled, the batch is no longer associated with the client. The batch runs on the Application Object Server (AOS). However, you have the option to make a batch run on a client. You will extend RunBaseBatch to override the run method. The run method contains the logic that handles the particular processing need that you are solving. runsImpersonated method is used to insist the batch to run automatically or under the authority of the person who scheduled the batch. runsImpersonated – if true run under authorized person. runsImpersonated – if false run automatically.

4. How to schedule the batch?
There are three main classes are needed to schedule the batch. They are BatchHeader batHeader; BatchInfo batInfo; RunBaseBatch rbbTask;
rbbTask = new Batch4DemoClass (); //Batch4DemoClass is the batch class. This batch will be scheduled After batch scheduled we can find the batch status if runsImpersonated is false Basic->Inquiries->Batch Job After batch scheduled we can find the batch status if runsImpersonated is true Basic->Periodic->Batch->Processing

5. What are Best Practices for AOS? Minimize the traffic between the server and the client. Put user interface related logic on the client. Run application logic (business logic) on the AOS. Put database related logic on the database server.
You should run methods on the server if they do one of the following: Have more than one select. Select more than a few records. Call methods on the server.
Every database operation passes through the AOS. If your code performs more than one operation on the database, it should run on the server. You should add the AOSRunOn hint to class static methods set to RunOnCalled from <tier>.
// AOSRunMode:: <tier>


Functional
Trade The most frequently modified modules in Microsoft® Business Solutions−Axapta® are the Accounts Receivable and Accounts Payable modules. For instance, the element that every company modifies is the printed sales invoice. This is sometimes a rearrangement of the data that is already available to the invoice, but is more often a complete redesign that includes additional data that is unique to them. The trade modules all revolve around buying and selling of inventory, and issue and receipt of payments. The AR and AP modules are similar in their structure with regard to both data dictionary and update procedures, and make good use of table maps to lessen the amount of coding needed. Accounts Receivable Sales order types Sales orders are used to create, maintain, and inquire about orders. You can choose between several sales order types.

The list below describes the sales order types:
Order Types
Description
Journal
Use the Journal order as a draft: it has no effect on stock quantities and does not generate item transactions. Order journal lines are not included in master scheduling
Quotation
Use quotation if the customer has not committed an order. Quotation generates issue lots with type Quotation in the inventory and optionally included in master scheduling
Subscription
Use subscription orders for recurring orders. When the order is invoiced, the order status is automatically set to open order. Quantities delivered invoiced and remaining deliveries are updated.
Sales order
Use sales order when the customer actually places or confirms an order.
Returned Item
Use returned item order when the customer returns items to stock. A return item number is needed.
Blanket order
Use blanket order if there is a contract with the customer and the customer wants to order from the contract. Create a release order to release, deliver, and invoice items until the contract is fulfilled. Blanket orders have no effect on stock quantities, do not generate item transactions, and are not included in master scheduling (unlike release orders that do).
It is possible to change an order type at any time except when an order has Status delivered.
Create a sales blanket order
1. From Account receivable, select Sales order.
2. In the top half of the Sales order form, press CTRL+N.
3. Select a customer. You are prompted if you want to transfer customer information.
4. In the Order type field, select Blanket order.
5. Enter or modify information if needed and click OK when completed.
6. In the bottom section of the Sales order form, press CTRL+N or click Functions, Create lines to create lines for the blanket order.
7. Select or type in item number, quantity, unit, unit price etc. Repeat this process for each order line required for the blanket order.

Note You can also create blanket orders through a journal, select Account receivable, Journals, Sales order, Blanket order. The Blanket order form works the same way as the Sales order form except that you can only create sales orders of the type Blanket order. Create sales release order
1. From Account receivable, select Sales order.
2. In the top half of the Sales order form, select the blanket order from which you want create a release order.
3. Click Functions, Create release order.
4. In the Create release order form, select lot ID, and enter quantity, delivery date and delivery address, if different from the blanket order. Note A release order has the order type Sales order and can be regarded as any other order of this type. Accounts Payable Purchase order types. Purchase orders are used to create, maintain, print, and inquire about orders in the company. You can choose between several purchase order types.

The list below describes the purchase order types:
Purchase order type
Description
Journal
Use as a draft; it has no effect on stock quantities and does not generate item transactions. These lines are not included in master scheduling.
Quotation
Use if the vendor has not committed an order. Quotation generates an issue lot with the type Quotation in the inventory and optionally in master scheduling.
Subscription
Use for repeated purchases of the same goods or services. When a packing slip is updated, Axapta generates a receipt lot. When the invoice is updated for the receipt lot, a new packing slip or invoice entry can be updated for the same purchase line. Quantity received, invoiced, and remaining is updated.
Purchase order
Use when the vendor confirms an order.
Returned item
Use when returning goods to the vendor. Return item number given by the vendor
must to be entered.

Blanket order
Use if there is a contract with the vendor and you want to order from the contract. Create a release order to release, order, and invoice items until the contract is fulfilled. Blanket orders have no effect on stock quantities, do not generate item transactions, and are not included in master scheduling (unlike release orders that do).

Create purchase blanket order
1. From Accounts payable, select Purchase order.
2. In the top half of the Purchase order form, press CTRL+N.
3. Select a vendor. You are prompted if you want to transfer vendor information.
4. In the Purchase type field, select Blanket order.
5. Enter or modify information if needed and click OK when completed.
6. In the bottom section of the Purchase order form, press CTRL+N or click Functions, Create lines to create lines for the blanket order.
7. Select or type in item number, quantity, unit, unit price etc. Repeat this process for each order line required for the blanket order. Note You can also create blanket orders through a journal, select Accounts payable, Journals, Purchase orders,

Blanket order.
The Blanket order form works the same way as the Purchase order form except that you can only create purchase orders of the type Blanket order. Create Purchase release order
1. From Accounts payable, select Purchase order.
2. In the top half of the Purchase order form, select the blanket order from which you want to create a release order.
3. Click Functions, Create release order.
4. In the Create release order form, select lot ID, and enter quantity, delivery date and delivery address, if different from the blanket order. Note A release order has the purchase order type Purchase order and can be regarded as any other order of this type.

AXAPTA’S MODULES Axapta offers the full breadth and functionality equivalent to other high-end products.

A complete listing of Axapta’s modules is provided below:

1. Financial Management - Comprehensive accounting, financial reporting, and analysis.
2. Business Analysis - Create, view, and understand multidimensional reports.
3. Object Server - Technology that minimizes bandwidth requirements and offers and secure client deployment.
4. Tools – Axapta’s tools allow you to tailor almost every aspect of Axapta, including user screens, reports, statements, tables, and fields.
5. Commerce Gateway - Supply chain solution.
6. Enterprise Portal Framework - Make your workflow smoother by allowing employees, customers, vendors, and other business partners to interact directly with your ERP system.
7. HR Balanced Score Card - Monitors business performance based on Key Performance Indicators (KPIs).
8. HR Business Process Management - Develop and manage business processes by identifying and monitoring actions.
9. Human Resource Management I - Helps you gather and structure employee information.
10. Human Resource Management II - Automate recruitment processes and employee absence analysis.
11. Human Resource Management III - Develop resources to meet your strategic goals.
12. Logistics - Streamline purchasing, production, customer demand, inventory, and other key areas of your business.
13. Master Planning – Produces product forecasts to project long-term needs for materials and capacity.
14. Product Builder – Web based product configurator allows you to configure complex products.
15. Production - Production I: Handles the material flow from suppliers, through production, to customers. Lets you plan and execute routes, operations, and rough capacity planning. Includes operation management and detailed production scheduling.
16. Shop Floor Control - Manage Personnel and Production - Register tasks, time, and material via bar codes. Create definitions of non-productive time. Obtain an overview of who is doing what, when, and how.
17. Trade - Automate Sales and Purchasing - Exchange sales and purchasing information electronically (in combination with the Commerce Gateway module). System automatically calculates tax and checks inventory and customer credit information. Picking and receiving documentation automatically generated. Automatic tracking of back orders. Automatic unit conversions.
18. Warehouse Management - Manage warehouses according to your individual needs. Optimize your Warehouse Layout to Increase Efficiency. Divide your warehouse into zones to accommodate different storage needs. Specify warehouse locations on five levels: warehouse, aisle, rack, shelf, and bin. The system helps you find the optimal storage location.
19. Project - Project I: Enter time, materials, and supplies consumption, and manage projects and financial follow-up for shorter-term time and material projects and internal projects. Project II: Advanced financial management for longer-term time and material projects, internal projects, and fixed-price projects.
20. Marketing Automation - Target Specific Audiences. Use prospect information to segment your target audience into meaningful profiles. Add and remove targets to meet your exact requirements. Import address lists.
21. Questionnaires - Design online surveys, such as customer or employee satisfaction, in a matter of minutes, without any technical experience. Search for survey participants in system by criteria for example, job title. Make surveys and results available via intranet or public web site.
22. Sales Management - Manage and Monitor Individuals, Teams, and the Entire Organization. Define sales targets for individuals, teams, and company. Track progress of activities, including pending sales quotes. Generate forecasts.
23. Sales Force Automation - Streamline Contact Management. One centralized place provides a quick status of customers, prospects, vendors, and partners. Make calls directly with a click of a button. System automatically detects incoming phone number and finds the contact card. Transaction log gives you an overview of who has been in contact with a prospect or customer and what has been done. Supports mail merge files and group e-mails.
24. Telemarketing - Manage Telemarketing Campaigns. Generate call lists by selecting fields, such as sales district, revenue, relation types, segment, and past sales behavior. Distribute call lists to salespeople and telemarketing staff who have already been in contact with target. Attach questionnaires and telemarketing scripts to call lists. Use call logs to check status of calls and create reports and future lists.
25. Sales & Marketing - Access relevant sales information. Access instant cost-benefit analyses of revenue for executed campaigns. Give your entire organization access to contact information. Make forecasts based on anticipated sales.

1. How many DataSources are present in the form Sales Table.
How many individual Queries.
Explain your answer.
A. In the SalesTable form Three Data Sources are present.
1. SalesTable.
2.SalesLIne.
3.InventDim
2. Is the InventDimParm a temporary Table?
A. It is a temporary table created according to which dimensions you have to use.
3. In which method is an InventDim record created A. InventDim.findOrCreate() method the InventDim record created.
4. Which class is used to create Inventory Transactions? A. InventMovement class is used to create update Inventory Transactions

1 comment: