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.