X++ code to get the Mandatory Fields in table in Ax 2012

Hi Friends, To day i would like to post a small job/Snippet which will be helpful in our day to day development to get the list of mandatory fields from a specified table.

Let me put it this way, some times we have to duplicate/Mimic a standard functionality without disturbing the standard flow/objects etc.etc..  in such cases this will be very helpful for us to get the list of mandatory fields from each table, instead of going to the each table and find out the properties.

Please find the below code snippet 

static void CheckMandatoryFieldsOnTable(Args _args)
{
        DictTable   dictTable;
        DictField    dictField;
        Counter      i;

        TableId       tableId = tablenum(SalesTable);//Table name
     
        dictTable = new DictTable(tableId);
 
        info(strFmt("Total No. of fields in: %1 are: %2\n\n\n",tableId2name(tableId),  dictTable.fieldCnt()));

        info('Mandatory Fields are following');

        for (i=1 ; i<=dictTable.fieldCnt() ; i++)
        {
            dictField = new DictField(tableId, dictTable.fieldCnt2Id(i));
            if (dictField.mandatory())
            {
                info(dictField.name());
            }
        }
}

Proud To Be a DAX Developer :-)

SSRS Tips: X++ code to get Company Logo in D365 F&O || Ax 2012

Hi Everyone, 

There are multiple ways for presenting Company logo in SSRS reports(i.e. RDP reports). Today I would like to share my way of inserting the company logo into  tempTable.

   // Variable declaration
   CompanyInfo        companyInfo = companyInfo::find();

How to write X++ methods on the list page Form in Dynamics AX 2012

Scenario: I have a menu item that calls some class to execute business logic on the list page Form. List pages do not allow writing of code on the Form, as they used interaction class.

Solution: You can write the code on list page buttons by setting DisplayTarget property to “Client” from auto, as shown in the below Fig:1.0


Fig: 1.0
Note: After this change, you won’t be able to use this button on the EP, so if you are thinking of using the same list page on the EP and planning to use the same button there, then do not do it. However if you are using only the Rich client Form then you are good to do this.

Proud To Be a DAX Developer :-) 

SSRS:How to create SSRS Reports using AOT Query & Auto design in Ax 2012

OverView:
There are multiple ways to develop SSRS reports in Dynamics AX. This tutorial will guide you through the process of developing SSRS reports using an AOT query and auto design.
Pre-requisites
  1. Microsoft Dynamics AX 2012
  2. Visual studio 2012
  3. SQL Server report server must be configured
  4. Reporting services extensions must be installed in Dynamics AX
Steps
  1. First of all we need an AOT query which will fetch data from AX and display it in a report. For this tutorial, I am using an existing query in AX which displays a list of customers.
  2. CustTableListPage query will be used in this tutorial. To find this query, open AOT àQueriesàCustTableListPage.
  3. The development of the SSRS report is done in Visual studio. So a new project needs to be created in Visual studio.
  4. Open Visual studio. Go to File à New à Project.
  5. In the section Installed templates select Microsoft Dynamics AX and then select Report Model in the right pane. Name the project “QueryBasedDemo“. Press OK.

Table Inheritance In Microsoft Dynamics Ax 2012

Table Inheritance :

  • A table can extend from or derive from another table. Each table has the SupportInheritance property and the Extends property, which together control table inheritance.
  • The default for each new table is to implicitly extend from the Common table. The extension from the Common table cannot be set or seen in the Extends property. A variable that is declared of a specific table also implicitly inherits methods from the xRecord class.
  • In the terminology for table inheritance, we say that the derived table extends its base table. But we never use the terms parent or child to explain tables in an inheritance relationship. The terms parent and child can be used to describe foreign key relationships between tables.
  • In Microsoft Dynamics AX, a table can inherit from another table. The AOT node for each table has the Extends property which you can use to derive your table from a table that you specify. 

Table inheritance is mainly controlled by the following properties:

  1. SupportInheritance – specifies if a table is a part of a hierarchy.
  2. InstanceRelationType – specifies the field that is used as a type discriminator. TableIds of concrete types are used as values of the InstanceRelationType field.
  3. Abstact – specifies if a table is abstract. Tables without derived tables cannot be abstract.
  4. Extends – specifies table’s parent.

Difference Between LinkType and JoinType in Dynamics Ax 2012

Hi Everyone today i would like share information on Link types and Join Types. 
  • Link type is a property of the form data source. We can add more than one tables as a data source to the form.
  • Those data sources should have the table level relation, So, that the developer don't need to work on the coding part to find the related records. 
For example, if we create the order form, that order form has orders and orderdetails tables as form data sources. We can add both tables as a data sources to the form.

Link Type:

  •  Active:  Parent and child- data source is updated immediately when a new record in the parent data source is selected. Continuous updates consume lots of resources consuming.

CrossCompany Vs ChangeCompany In Dynamics Ax 2012

Hi Everyone today i would like share information regarding how to retrieve data from Selected companies or from a specified company by using Keywords known as CrossCompany and ChangeCompany in Dynamics Ax, with a simple example.  

CrossCompany :  By using this keyword we can retrieve data from multiple selected companies or from all companies.
Example:-  We'll be using the well known demo data table (i.e, CustTable).

                    CustTable                 custTable;
                    Container                  con;
                 // Assigning the required Companies to the container 
                    con = ["CEU","DAT","CEE"];
                // CrossCompany:Object is the syntax for using CrossCompany keyword
                    Select crosscompany:con custTable;
                    
info( strfmt("%1",custTable.accountnum));

ChangeCompany : By using this keyword we can change company any time and retrieve data from specific companies. 

For Easy Understanding: Let say i'm in the CEU Company and i would like to get the data belonging to the CEE Company. Then i would Prefer to Use ChangeCompany Keyword.

Example:-
                    CustTable                 custTable;
                    Select * from custTable;
                    
info( strfmt("%1",custTable.accountnum));
//Accessing the data from a specified company by using the ChangeCompany Keyword
// changecompany("Company Name")  is the Syntax for ChangeCompany Keyword.
                    changecompany("CEE")
                    {
                        
custTable = null
                        Select * from 
custTable;
                        
info( strfmt("%1",custTable.accountnum));
                     }
// Retrieving from another selected Company
                    changecompany("CEEU")
                    {
                         
custTable = null
                         Select * from 
custTable;
                         
info( strfmt("%1",custTable.accountnum));
                     }                    

Proud To Be a DAX Developer :-)

What Is The Difference Between OCC and PCC in Ax 2012

Optimistic Concurrency Control (vs) Pessimistic Concurrency Control

Pessimistic Concurrency Control :
                                                    On updating the data, the record gets locked and no one else can access that record for updating. It becomes a read-only record till the lock is released. Once the lock gets released, the record can be locked again and get updated for a different user.

Optimistic Concurrency Control :
                                                    This allows multiple user to open up the same record for updation . Record gets locked only while updating the record. This is the most preferred way of locking for the web application.

Proud To Be a DAX Developer :-)

Calling Sequence Of Methods In FORM Level in Ax 2012

Hi Every one, today i would like to share my knowledge on Calling Sequence Of Methods in Form Level. Each form has a set of standard methods. You can override these methods to change the behavior of the form, respond to user interface events, and customize the appearance of a form.There are also methods on each form data source and on each form control.
Below scenarios gives the information of  method calls in the form level 
  1. Opening the Form.
  2. Creating/Updating/Deleting the record in the Form.
  3. Closing the Form.