Home

Thursday, June 26, 2014

AIF

https://community.dynamics.com/ax/b/alirazatechblog/archive/2014/01/05/short-introduction-to-aif-framework.aspx

List of framework in Dynamics Ax 2012

There are a lot of frameworks in Dynamics Ax 2012 a Few of them listed as follow.
  •                 Address Book
  •                 Application Integration Framework (AIF)
  •                 Budget Control framework
  •                 Data Import Export/Data Migration framework
  •                 Date Effective
  •                 Eventing Framework
  •                 Extensible Security Policy (XDS)
  •                 Human Resources Framework
  •                 Number Sequence
  •                 Organization Model
  •                 Policy Framework
  •                 SQL Server Rerporting Services (SSRS)

Wednesday, June 25, 2014

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.

Security – AX 2012

disabling form elements based on another form elements

count Records using X++ in Query + ax


Following code illustrates how we can use SysQuery::countTotal() method to get the number of records in Query.

static void Query_cntRecords(Args _args)
{
Query query = new Query();
QueryRun queryRun;
QueryBuildDataSource qbd;
;

qbd = query.addDataSource(tablenum(CustTable));
queryRun = new QueryRun(query);

info(strfmt("Total Records in Query %1",SysQuery::countTotal(queryRun)));

}

DAX- UTC date time, different time zone show differerent time on form and code(classes)

UTC date time field always store values as GMT or UTC on database
While displaying on forms it convert and display it automatically by user preferred time zone.
But when you access it through code in Classes , you will get the UTC date time (without time zone difference). So you need to convert it first before using for any calculation and comparison.
static void Job22(Args _args)

 {

                utcDateTime utc3 = str2datetime( “1985/07/27 23:04:59″ ,321 );

                 info(strFmt(‘%1′ ,DateTimeUtil::applyTimeZoneOffset( utc3, DateTimeUtil::getUserPreferredTimeZone())));

 }
For more information please visit following link
http://msdn.microsoft.com/en-us/library/cc584924.aspx

Sequence of methods in the FORMS and Table level in AX


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

Table:

When you press CTR+N
initValue()->

When you change data in a field
validateField() -> validateFieldValue() -> ModifiedField() -> ModifiedFieldValue()

When you close the table after entering some data
validateWrite() – > Insert() -> aosValidateInsert()

When you Save the Record for the first time
validateWrite() ->Insert() – > aosValidateInsert()

When you modify the record and saving
validateWrite() -> update() – > aosValidateUpdate()

When you delete the record
validateDelete() -> delete() -> aosValidateDelete()

Thursday, June 12, 2014

Microsoft dynamics ax interview questions

 Name the two dynamics framework newly added on Ax 2012

Explain ledger framework in AX 2012
In AX 2012 journal postings are running on IL code. So how do you debug the posting
What are all the steps in Dynamics ax 2012 upgradation. in which level you worked extensively explain it.
Name the two newly added best practices in Dynamics ax 2012 on all the AOT objects
Explain the table inheritance in AX 2012 with examples
Consider the situation that huge number of invoices happening on the particular company. so Client wants you to modify something on the invoice place. so what are all the steps would you take to prevent fall of performance in the system
Have you worked on SSRS.
When user wants to open the SSRS report I want some user input for the report. What are all the steps to get user input. (here I explained about the controller classes and dialogs to get user inputs)
Ok I need a lookup in that SSRS dialog field. how do you achieve it. what are all the classes you use.
Explain the types of way to get Data sources in SSRS report
Explain the data methods in SSRS report. what is the purpose when did you use it
Explain post handler and pre handler in AX 2012
how do you get the exchange rate for transaction currency (here I explained about exchangeratehelper class)
Explain trade agreements and their use
Explain model and model store
say some scripts you used at the time of data migration
How do you migrate the changes from Development to UAT
What is inbound and outbound
Explain the steps for creating services in dynamics ax
Explain the real time steps for development (Interviewer asking about the series of real-time development lifecycle in dynamics ax. This actually a tricky question here you have to explain the document preparation and step by step development process from Requirment to TDD)

Retrieve multiple selected records from Grid using X++. in AX dynamics 2012

Retrieve all selected records of a datasource in a Grid


    int             recordsCount;
    Student     studentLocal;
    super();
    
    recordsCount = student_ds.recordsMarked().lastIndex();  // Total no of marked records.
    studentLocal = student_ds.getFirst(1);
    
    while (studentLocal)
    {
        info(studentLocal.Name +" " +studentLocal.ID);
        studentLocal = student_ds.getNext();
    }

Ax 2012 SSRS Reporting concepts

The picture is self explanatory and just to brief things up:
Basically a Report Model can contain Reports, Layout Templates, Table Style templates, Report Database etc..
And nodes which we can find under Report/Report Model are Datasets, Desgin, Parameters, Data methods and Images.
In Ax terms, a Datasets can be said to be a data source and collection of fields from data source.
And basically an Ax Query, SQL Data, OLAP data (cube) and a Data method can act as a Data source for a report
Design node of a Report/Report model will contain three major parts, namely, Header, Body and Footer.
And the Desgins can be of two types, namely Auto Design and Precision design.
Dynamics Ax will take of the conversion form the Designs to RDL files, the format in which reports are stored in the SQL Database.

Internal links:
SSRS Ax 2012: How to create a simple SSRS report - Link
SSRS Ax 2012: How to design reports with built-in templates - Link

Monday, June 9, 2014

Using Optional Parameters [AX 2012]




It is possible to initialize parameters in the method declaration. This makes the parameter an optional parameter. If no value is supplied in the method call, the default value is used.

Code Example 1: Function used as the Default

The following methods are considered to be members of the MyClass1 class, which includes the field member birthDate.
public class MyClass1  // classDeclaration
{
    date birthDate;
}
Next, the class contains a constructor that takes a date type as a parameter. That value is assigned to the field member birthDate.
void new(date _date)
{
    birthDate = _date;
}
Next is the CalculateAgeAsOfDate method, for which the following are true:
  • The method references the birthDate field.
  • The method has an optional parameter. In this example, the default value is the return value of a function.
  • The method is called by the Main method.
public real CalculateAgeAsOfDate  // X++
        ( date _calcToDate = today() )  // Parameter is optional for callers.
{
    return (_calcToDate - birthDate) / 365;
}
Next is the Main method which calls the CalculateAgeAsOfDate method twice.
static public void Main(Args _args)
{
    MyClass1 mc = new MyClass1(13\5\2010);   // birthDate is initialized.

    // Optional parameter's default is used.
    print "Age in years: " + num2str(mc.CalculateAgeAsOfDate(),2,0,0,0);

    // January 2, 2044  is the parameter value for _date.
    print "Age in years: " + num2str(mc.CalculateAgeAsOfDate(2\1\2044),2,0,0,0);

    pause;
}

Code Example 2: Invalid Sequence of Parameters

All required parameters must be listed before the first optional parameter. In the following invalid example, the required parameter _i3 is listed after the optional parameter _i2.
static public int AddThreeIntsA  // Invalid X++, does not compile.
        (int _i1,
         int _i2 = 3,
         int _i3)  // Required parameter cannot follow an optional parameter.
{
    return _i1 + _i2 + _i3;
}

Code Example 3: Cannot Skip to Second Optional Parameter

When calling a method, the caller cannot override the default value of the final optional parameter unless the caller also overrides the default values of every other optional parameter.
In the following example, the first method has two optional parameters. The second method is a caller of the first method. The caller wants to override only the _i3 default value, but the compiler requires that all prior optional parameters also be overridden in the call.
static public int AddThreeIntsB
        (int _i1,
         int _i2 = 2,
         int _i3 = 3)
{
    return _i1 + _i2 + _i3;
}
Next, the second method has a commented section showing the failed attempt to accept the default of the first optional parameter _i2 while trying to override the final optional parameter _i3.
static public void Main(Args _args)
{ 
    // No way to skip the first optional parameter (so it can default)
    // while also specifying the value of the second optional parameter.
    //
    //print MyClass1::AddThreeIntsB(1, , 99);  // Would fail to compile in X++.


    // Settle for overriding both optional parameters.
    //
    print MyClass1::AddThreeIntsB(1, 2, 99);
    pause;
}

Thursday, June 5, 2014

Upadate record based on Enum value

static void Job2(Args _args)
{
  MyTable mt;
    ttsBegin ;
    while select forupdate mt where mt.RecId!=0 && mt.RecId < 5637146329
    {
        if(mt.Gender ==Gender::Male)
        {
        mt.Gender =Gender::Female;
        }
        else if(mt.Gender ==Gender::Female)
        {
          mt.Gender =Gender::Male;
        }
        mt.update();
        info("done");
    }
    ttsCommit;
}