Monday 22 January 2018

Table Method Calling Sequences in Ax -2012

          Table Method Calling Sequences in Ax -2012

When we are opening the table and Press CTrl+N
----> InitValue()
When we are Change data in a field.
àValidateFieldValue() à validateField() àModifiedFieldValue() àModifiedField().
When we are save the table after entering some data and close the table.
àvalidateWrite() à aosvalidateInsert() à Insert().
When we are Open the Table which will contain some data.
à  aosValidateRead ().
When we are Save the Record.
à ValidateDelete() à aosValidateInsert() à Insert().
When we are modifying the record.
àValidateDelete() à aosValidateUpdate() à Update().
When We are delete the Record.
àValidateDelete() à aosValidateDelete() à Delete().

Examples and Methods Working Progress.
I have taken Student Table and enter some Records.
When we are opening a Table Below Methods will be calling.
Open table: 1. PostLoad,2. aosValidateRead.

When we are Create New Record or CTrl+N.
Then below method will be Calling.
New Record:1. InitValue

When we are move to Next Field then below methods will be calling.
Move Record: validate Field Value, Validate Field, Get Extension, Modified field Value, preremoting, aosValidateInsert, insert, Preremoting, Modified.

When we are Modifying The record then below methods will be calling.
Modify Record: Validate Field Value, ValiadteField, get extension, modified Field Value, Preremoting, aosValidateInsert, Preremoting, Modified Field.


When we are Update the Record then below Method will be Calling.
Update Record: Validate Field value, Validate Field, Get Extension, Modified Field Value, Preremoting, aosValidateInsert, insert, Preremoting, Modified Field, Validate write, Preremoting, aosValidateUpdate, Update, Preremoting.

When we are delete the Record then below Methods will be calling.
Delete Record:  Validate Delete, Preremoting, aosValidateDelete, Delete, Preremoting.
When we are save the record then below methods will be calling.

Save Record: Validate Write, Preremoting, aosValidateUpdate, Update, Preremoting.

When we are open the Form Then Called table of Help Field Method and Caption Methods.

Caption ():


Help Field ():
àRetrieves the help text of the control.
public str helpField(FieldId _fieldId)
{
    str     ret;
    str     name;

    ret = super(_fieldId);
    //info("Called helpField Method");
    name = this.helpField(1);
    return ret;
}
Caption ():
àGet and set the Caption property of a table.
public str caption()
{
    str ret;

    ret = super();
    info("Called caption Method");
    ret = strFmt("%1 %2",this.StudentId,this.StudentName);

    return ret;
}

Clear ():
àRemove all Rows from the table Buffer.
This. Clear ()
Tablebufffer.Clear();
Equal ():
àDetermines Whether the specified Object is Equal to the Current one.
static void Na_equal(Args _args)
{
    VendTable       vendTable;
    VendTable       v1,v2;

    v1 = vendTable::find("1003");
    v2 = vendTable::find("1003");
    info(strFmt("%1",v1.equal(v2)));

}
ReturnsàTrue  Or false.
Post Load ():
àIs Executed after Record Is Read.
it is used to read records from database and you can perform any custom logic by overriding this method on any table.

Executed when record loaded.
public void postLoad()
{
    super();

    if (this.Name == 'MEL')
        this.Value = 5;
}

Merge ():
àMerges the current table with the specified table.
static void merge(Args _args)
{
    Na_ClassTable       na_ClassTableDelete;
    Na_ClassTable       na_ClassTable;
    //ReasonTable reasonTableDelete;
    //ReasonTable reasonTable;

    ttsBegin;
        select firstOnly forUpdate na_ClassTableDelete
            where na_ClassTableDelete.Address == 'Guntur';
        select firstonly forupdate na_classtable
            where na_classtable.address == 'hyderabad';

    na_ClassTableDelete.merge(na_ClassTable);
    na_ClassTable.doUpdate();
    na_ClassTableDelete.doDelete();
    ttsCommit;
}

Using List Class and Merge.

static void Na_ListMerge(Args _args)
{
    List list1  = new List(Types::Integer);
    List list2  = new List(Types::Integer);
    List combinedList  = new List(Types::Integer);
    int  i;

    for(i=1; i<6; i++)
    {
        List1.addEnd(i);
    }
     for(i=6; i<11; i++)
    {
        List2.addEnd(i);
    }

    combinedList = List::merge(list1, list2);
    info(strFmt("%1",combinedList.toString()));
    //pause;
}
Preremoting ():
àIs Executed Before a Cross-tire call being about to Executed for the Table That Would Pack its state to the Other tier.
get Extension ():
àReturns the Table extension.
get SQL Statements ():
àit is used to Return record from the database.
                ReturnsàString;
get Field Value ():
àGets the Value of the Specified field from a table buffer.
                Returnsàany type;
ISFormDataSource ():
àIndicates Whether the Data Source is a Form.
                ReturnsàBoolean;
Get Presence Field Data ():
àRetrieves the presence info value from the specified field.
                ReturnsàFieldId—EDT;FieldValue—any type.
Default Field ():
àPopulates Default values in a Field in the table.
Default Row ():
àPopulates Default values in a Field in the table in the non-interactive case.
Write ():
à Updates a Record if it exists otherwise insert Record.


Wait ():
à The most common use for this method is to start an object that asks the user for some input and then call the wait method on that object, such as a form. The next line of code is not executed until the object has called the notify or notifyAll method.
When the wait method is called from a form, you do not have to call the notify methods manually because forms call the Object.notifyAllmethod when the user either closes the form or presses the Apply button.
.
Reread ():
à Current Record from the database. It should not use to refresh the form data.
                 Data if you have added/removed records. It's often used if you change some values in the current   record in some code, and commit them to the database using. update () on the table, instead of through the form data source. 
To String ():
à Returns a string that represents the current object.
static void Na_tostring(Args _args)
{
     Object obj = new Object();

    info(strFmt("%1", obj.toString()));
  
}
Table Access Right ():
à Returns the table access right.
è Type- Access Right Enumeration.
   like –NoAccess,View,Edit,Add,correction,delete.(0,1,2,3,4,5).

Buf2Con () && Con2Buf ():
à Converts a record into a container. (or) Converts Table Buffer Record to container.
à Converts a container into a record. (or) Converts container to Table Buffer Record.

static void Na_buf2con(Args _args)
{
    Na_ClassTable    na_ClassTable;
    Na_ClassTable    na_ClassTable2;
    container       packedTable;  
   
    ttsBegin;  
    na_ClassTable.StudentId = "Stu_119";
    na_ClassTable.insert();
    info(na_ClassTable.StudentId);
    info(na_ClassTable2.StudentId);
    ttsCommit;
    // pack
    packedTable = buf2Con(na_ClassTable);
    // unpack in a different table buffer
    na_ClassTable2 = con2Buf(packedTable);
    info(na_ClassTable2.StudentId);
    if (na_ClassTable2.StudentId == na_ClassTable.StudentId)
    {
        info("Values are equal");      
        info(na_ClassTable.StudentId);
        info(na_ClassTable2.StudentId);
    }
}




Microsoft Dynamics AX Extended Architecture.

Microsoft Dynamics AX Architecture.
Microsoft Dynamics AX has a three-tier architecture.


Three-tier architecture got its name from the way it separates database, business logic and UI parts of application : 
·                     The database layer or data access layer interacts with the data.
·                     The application business logic is the tier where business rules are enforced.
·                     The UI allows users to connect to the business logic and use the data in the database.
In MS-Dynamics AX the three tiers include the following:
·                     A SQL Server Database that stores the data entered into, and used by, the Microsoft Dynamics AX application. It also stores the model store that contains the application elements. 
·                     An Application Object Server (AOS) is a service that runs most of the business logic. This runs continuously on a central server.
·                     The Client application is the user interface through which an end user accesses Microsoft Dynamics AX. There are various clients available including the Microsoft Dynamics AX rich client and Enterprise Portal.



                                                             Extended Architecture

Several other components of the Microsoft technology stack are used in a typical deployment.

Reports are delivered by SQL Reporting Services (SSRS). SSRS is a component included in SQL Server.

Business Intelligence (BI) components such as Key Performance Indicators use Online Analytical Processing (OLAP) cubes which are delivered by SQL Analysis Services (SSAS). SSAS is a component included in SQL Server.

The Enterprise Portal and Role Pages are hosted in SharePoint. There are two versions of SharePoint that can be used. Window SharePoint Foundation 2010 is a free download. Microsoft SharePoint Server 2010 is a product that can be purchased to provide extended collaboration and content management tools.

Integration to other applications or to third party organizations might require integration solutions such as web services.

The following image describes a typical system architecture that includes other
components of the Microsoft technology stack.

 



SQL Server Databases

Microsoft Dynamics AX Database

The Microsoft Dynamics AX database is an Online Transactional Processing (OLTP) database that stores all the business data in SQL tables. This database also stores all of the metadata and application code in the Model Store.

Business Intelligence (BI) Databases

Some BI components of Microsoft Dynamics AX also require you to use SSRS and SSAS. The SSAS database is replicated from the OLTP database in a database format that is optimized for fast reporting and analysis.

Application Object Server

The Application Object Server(AOS) is the Microsoft Dynamics AX application server. The AOS is where most of the business logic is executed.

The AOS performs many tasks. Some of the most important tasks include:
·                     X++ runtime:It runs the X++ code which provides most of the business logic in MS Dynamics AX.
·                     Security:It enforces security to manage access to data and functionality.
·                     Session management: It manages client sessions.
·                     Web services:It is a web service endpoint.


Multiple AOS's can be installed to spread the processing load over multiple servers. This improves performance in larger implementations.

Clients

Microsoft Dynamics AX Rich Client is the primary client to access Microsoft Dynamics AX functionality. Most forms displayed in the rich client are designed by using the MorphX development environment. 

Role center pages are SharePoint pages that are displayed within a rich client form. SQL reports are called from the rich client by using the report viewer control.

Enterprise Portal pages are displayed through a web browser. A subset of functionality and reports are available on the portal.

Microsoft Office can be used as a client to access the Microsoft Dynamics AX application and data. Office add-ins are available out-of-the-box for Microsoft Excel and Microsoft Word.

Other Applications can be used as a client to the Microsoft Dynamics AX application. Examples include mobile applications, specialized applications written in .net and legacy applications. Applications can be integrated using methods such as web services or the .net business connector. 

The .NET Business Connector is a client that has no user interface. It is designed for other applications to access the Microsoft Dynamics AX business logic. End-users can use another application as the user interface that interacts with the AOS through the .net Business Connector. 

Developers can access the developer tools through the MorphX IDEin the Microsoft Dynamics AX client or through Visual Studio Tools in Visual Studio.

Other Components

Internet Information Server (IIS) - IIS is a web server that delivers content such as web pages.

Enterprise Portal and SharePoint - IIS is required to host the Enterprise Portal framework within SharePoint. Role Centers require the Enterprise Portal regardless of whether they are viewed through the web browser or the Microsoft Dynamics AX Windows Client.

Help Server - MS Dynamics AX Help files are hosted through IIS. When a user accesses
Help from within the rich client, the AOS generates a call to the Help server to display the Help pages.

Web Services - Web Services are hosted within IIS. The AOS is the web service endpoint that provides the data that is served to other applications by IIS in a standardized.