30 Jan 2013

Table Methods with example + AX 2012

Some of table level methods with example.

Caption:: Displaying caption in the form...we can give more caption through caption method.
                 in table level Title field 1,2 also use for caption....but through caption we can give more  
                 captions..

EX::        Public str caption()
               {
                   return strfmt("Name:%1, AccNum:%2, Place:%3", this.Name, this.Accnum,
                                           this.Place);
                }

initValue:: If u want initializing some value when you create a record means when u want to
                      inserting  values into table in that time by default that value came....

                                           For example StudentTable with 5 fields in that one field is "Location" all the Students are same place like JNTU.
when we creating records  in "INITVALUE" will take care of this..     

                we wrote like this

                      EX:: public void initValue()
                        {                           super();                          this.Location= "JNTU";                          }
INSERT::  for record inserting purpose we are use this method.
                             ;
                              ttsBegin;
                              select forUpdate carTable;
                              carTable.color= 'REd';
                              carTable.Name = Benz;
                              carTable.insert();
                              ttsCommit;
Update:: Record updateing purpose we use this one...
 Delete:: Record deleting purpose we use this one..         
ValidateDelete()::Before deleting a record if we want to put any validation we can use this method.
                             
EX::                  public boolean validateDelete()
                         {
                           boolean ret;
                           ret = super();
                          if(this.AccNum==1111);
                           {
                               throw error("you cant delete this account number");
                            }
                               return ret;
                           }
ValidateWrite()::  This method will get to activewhen we update a record. here I am using to check 
                               mandatory field for address AccountNum
                  EX::  public boolean validateWrite()
                          {
                             boolean ret;
                              ;
                             if(this.Accnum!= "")
                             ret = super();
                             else
                             warning(" Accnum is mandatory");
                              return ret;
                             }

ModifiedField()::   This method will execute if modified a record value, menas if one field is
                                   change based on effect another field for that purpose we use this one..
                       EX::  public void modifiedField(fieldId _fieldId)
                                {
                                CarTable ct;
                                 ;
                                super(_fieldId);
                                switch(_fieldId)
                                  {
                                    case fieldNum(Car2,Company) :
                                    {
                                       this.Name = CarTable ::find(this.color).Name;
                                    }
                                    break;
                                  }
                                }   
               


No comments:

Create number sequence in D365 FO

Create the data type. Add code in the loadModule method of the appropriate NumberSeqModule subclass. Add a method to the module’s paramet...