Sunday, August 28, 2011

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 ()

 

Saturday, August 27, 2011

Microsoft Dynamics AX 2012 E - Learning

Hi...

Some important usefull stuff for AX 2012 in the link...
https://dynamics.microsoftelearning.com/

Exporting the Data from AX to CSV file

Hi....
Here is an example of exporting the AX data to a CSV file ...

static void ExportDataToCSV(Args _args)
{
    Query                             q;
    QueryBuildDataSource    qbds;
    QueryBuildRange            qbr;
    QueryRun                       qr;
    CommaIO                       commaIO;
    FileName                        fileName;
    InventTable                     inventTable;
    ;
   
    fileName       = WINAPI::getTempPath() + "ItemDetails" + ".csv";
    commaIO      = new CommaIO(fileName,'W');
   
    q                  = new Query();
    qbds             = q.addDataSource(tablenum(InventTable));
    qbr               = qbds.addRange(fieldnum(InventTable,ItemId));
   
    qr                = new QueryRun(q);
   
    commaIO.write("ItemId","Item Name","Item Type","Item GroupId","Dimension GroupId","Model GroupId");
    while( qr.next() )
    {
        inventTable = qr.get(tablenum(InventTable));
       
        commaIO.write(inventTable.ItemId,inventTable.ItemName,enum2str(inventTable.ItemType),inventTable.ItemGroupId,
                      inventTable.DimGroupId,inventTable.ModelGroupId);
    }
   
    WINAPI::shellExecute(fileName);
}

Saturday, August 20, 2011

Creating The Number Sequence For The Existing Module

To create a numbersequence for the Existing module.

Suppose in my HRM Module for the Employee Table I have to create the NumberSequence (EmplTable).

I need to follow these steps to create the NumberSequence.

1.Go to the Classes -> NumberseqReference_HRM (Class) -> LoadMethod

2.In the load method you have to override the code , need to added the code to which field we are planning to add the code that it can be copied from the exisitng code and modfiy the EDT which we want to add ( Here My EDT is EmplId)

Let us Assume (Existing Code )
numRef.DataTypeId = typeId2ExtendedTypeId(typeid(HRMApplicationId));

For The Empl Id We have to add the code means

numRef.DataTypeId = typeId2ExtendedTypeId(typeid(EmplId));


3.After completing the above procedure, we have to go to AOT -> Tables ->HRM Parameters -> Need to Override the code in the method

Ex: The Overrided code is


static client server NumberSequenceReference numRefEmplId()
{
return NumberSeqReference::findReference(typeId2ExtendedTypeId(typeid(EmplId)));
}


4.After the above step go to the Empl Form -> Form Level Methods u have to write the number sequence formhandler method have to create the code.


Class declaration Code
IN the class declaration we have to write the code

NumberSeqFormHandler numberSeqFormHandler;

Numberseqformhandler Code
In the Numberseqformhandler write the below code


NumberSeqFormHandler numberSeqFormHandler()
{
if (!numberSeqFormHandler)
{
numberSeqFormHandler = NumberSeqFormHandler::newForm(HRMParameters::numRefEmplId().NumberSequence,element, EmplTable_ds, fieldnum(EmplTable, EmplId));
}
return numberSeqFormHandler;
}


5.Then we have to Override the DataSource Methods ( Create, Write ,Delete).



Write Method Code is

element.numberSeqFormHandler().formMethodDataSourceWrite(); ---- After Super

Create Method is

element.numberSeqFormHandler().formMethodDataSourceCreatePre(); - Before Super
super();
element.numberSeqFormHandler().formMethodDataSourceCreate(); --- > After Super


Delete Method Code Is

element.numberSeqFormHandler().formMethodDataSourceDelete();---- After Super

6.After completing all the above steps.

7.Go -> HRM Module -> Setup -> Parameters -> Numbersequence

8.We have to add the reference for the EMP ID.

Saturday, August 13, 2011

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

Sunday, August 7, 2011

How to setup alerts for multiple users in Ax

In standard AX there is functionality for setup alerts only for the single user..
I came across in one the blogs, the functionality is customized to mutiple users in AX.
I just wanted to share this link to all...
Check out over here for,How to setup the alerts for mutiple users....


Wednesday, August 3, 2011

How to develop a new “Parameters form” in case of New Module developed in AX.

How to develop a new “Parameters form” in case of New Module developed in AX.
We go through it by considering an example of creating the new module as Payroll.
So now we will create the Payroll Parameters setup form for the payroll module.
Initially create a Parameters table for the Module, the naming convention should be the Module name followed by Parameter as in this case it is PayrollParameters table….and need to have the fields accordingly what is required in the Parameters table.
Set the following properties for the parameter table as…

Create a parameter form by considering the PayrollParameters and NumberSequenceReference as data sources. And set the following properties for the data source in the form level as

First thing is that there shouldn’t be any provision to create the record in the parameters form. The record in the Parameters should be by default and it can be updated as per the functionality required
So when creating the new company in the Axapta, the parameters form should have the default values.
To have the default values in the parameters we need to have the following code in the  table  level of find() of PayrollParameters tables .
static PayrollParameters find(boolean _forupdate = false)
{
    PayrollParameters  parameter;

    if (_forupdate)
    parameter.selectForUpdate(_forupdate);

    select firstonly parameter
        index Key
        where parameter.Key == 0;

    if (!parameter && !parameter.isTmp())
    {
        Company::createParameter(parameter);
        NumberSeqReference::construct(PayrollParameters::numberSeqModule()).load();
    }

    return parameter;
}


Tuesday, August 2, 2011

Displaying the PageNum/Total Pages in the report header

Displaying the PageNum/Total Pages in the report header...

For example: If a report contains a 10 pages then in the pager header it should be displaed as
Page 1 of 10,Page 2 of 10.....Page 10 of 10

Write these 2 methods in the report header
//Method to get the page number for every page in the report....
display int page()
{
    return element.page();
}
//Method to get the total pages in the report for every page...
display int pages()
{
    return element.pagesTotal();
}
Arrange these controls according in the design to display in the report..