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);
    }
}




No comments:

Post a Comment