Friday, November 2, 2012

X++ Code Optimzation

Following are the coding tips to improve your Axapta system's performance:
1. Smart Joins : Try to Use Joins instead of nested while loop 
wherever possible.
2. Select Statement : Mention the field names in the select statement 
instead of feteching entire row , this will reduce 
data amount to transfer from database.
e.g " Select Itemid from inventTable "

3. Display Methods : Make sure that generic display methods should be 
moved at table level and cached by 
using"Formdatasource.cacheAddmethod". 
4. Local caching : Use Variables for storing the constantly used 
caculated values in loop , by doing so you can 
reduce the calls to the database and different 
layers.
5. Monitor the Database Calls : For bulk records 
updation,deletion,insertion use 
RecordSet Based operator like 
update_recordset , delete_from and insert_recordset .
6. Aggregate Function: Use sum, avg, minof, maxof and count where 
applicable. Because this can utilize the database’s 
built-in function instead of calculating and analyse 
data in Axapta.

Source : http://learnax.blogspot.in/2010_01_01_archive.html

Copying License in Dynamics Ax


Axapta stores the License data in the following two tables.

1.SysLicenseCodeSort
2.SysConfig

So if you copy data of these tables(from Running instance) and import at your instance , this will serve your purpose.

Thursday, November 1, 2012

Temporary data insert



CustTable  CustTableTmp;
;
CustTableTmp.setTmp();
while select CustTable
{
    CustTableTmp.data(CustTable.data());
    CustTableTmp.doInsert();
}

Select CustTableTmp;

Wednesday, October 31, 2012

How to enable / disable form control through code in Ax 2009

Hi Friends,

I was designed new form for one of the functionality and while opening the form i suppose to set the properties of form controls. For this i  used the following line code.

1. Set the Auto Declaration property to true for that form control.
2. In the general methods of the form override the init() method.
3. In Init method after super() i used the following code line to set the properties
    
    element.control(control::ControlName).enabled(false);
    E.g. element.control(control::ToDate).enabled(false);

4. While writing this line of code you will not get any intellisense after Control::
     You have to just type your control name and compile the method and it's done.

Hope this will help anyone.

Kiss'shor.. :)

Monday, October 29, 2012

Date functions in AX 2009

Hi....

These are some of the functions,from where we can get the day or month or year from the date...
Here is the below example....

static void date_Functions(Args _args)
{
    Transdate    d;
    ;
    
    d = today();
    
    info(strfmt("Date - %1",d));
    
    //Gets the month for the given date...
    info(strfmt("Month - %1",mthofYr(d)));
    
    //Gets the month name from the given date...
    info(strfmt("Month Name - %1",mthname(mthofYr(d))));
    
    //Gets the day for the given date...
    info(strfmt("Day - %1",dayOfMth(d)));
    
    //Gets the day name from the given date...
    info(strfmt("Day Name - %1",dayname(dayOfMth(d))));
    
    //Gets the year for the given date...
    info(strfmt("Year - %1",year(d)));
    
    //Gets the current weekday number from the date...
    info(strfmt("Weekday number - %1",dayOfwk(d)));
    
    //Gets the day of the year from the given date...
    info(strfmt("Day of year - %1",dayOfyr(d)));
    
    //Gets the week of the year from the given date...
    info(strfmt("Week of the year - %1",wkofyr(d)));
}

Source : http://kollidynamics.blogspot.in/search?updated-max=2011-08-27T02:41:00-07:00&max-results=4&start=8&by-date=false

Sequence of methods in the FORM level in AX


Hi...

This gives the information of method calls in the form level while
1. Opening the Form.
2. Creating/Updating/Deleting the record in the Form.
3. Closing the Form.
Sequence of Methods calls while opening the Form
Form --- init ()
Form --- Datasource --- init ()
Form --- run ()
Form --- Datasource --- execute Query ()
Form --- Datasource --- active ()

Sequence of Methods calls while closing the Form
Form --- canClose ()
Form --- close ()

Sequence of Methods calls while creating the record in the Form
Form --- Datasource --- create ()
Form --- Datasource --- initValue ()
Table --- initValue ()
Form --- Datasource --- active ()

Sequence of Method calls while saving the record in the Form
Form --- Datasource --- ValidateWrite ()
Table --- ValidateWrite ()
Form --- Datasource --- write ()
Table --- insert ()

Sequence of Method calls while deleting the record in the Form
Form --- Datasource --- validatedelete ()
Table --- validatedelete ()
Table --- delete ()
Form --- Datasource --- active ()

Sequence of Methods calls while modifying the fields in the Form
Table --- validateField ()
Table --- modifiedField ()