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