Thursday, August 25, 2016

Extracting all possible ledger combinations in account structure

This post describes how to extract all possible ledger combination in accounts structures. 

Execute the following job to obtains all valid combinations.

static void srclJobExtractAllAccountStruct(Args _args)
{
    DimensionHierarchy                  dimensionHierarchy;
    DimensionAttribute                  dimensionAttribute;
    DimensionHierarchyLevel             dimensionHierarchyLevel;
    DimensionConstraintNode             dimensionConstraintNode;
    DimensionConstraintNodeCriteria     dimensionConstraintNodeCriteria;
    
    setPrefix('Account Structures Combination');
    
    while select Name from dimensionHierarchy
        where dimensionHierarchy.StructureType == DimensionHierarchyType::AccountStructure
    join RecId from dimensionHierarchyLevel
        where dimensionHierarchyLevel.DimensionHierarchy == dimensionHierarchy.RecId
    join Name from dimensionAttribute
        where dimensionHierarchyLevel.DimensionAttribute == dimensionAttribute.RecId
    join RecId from dimensionConstraintNode
        where dimensionConstraintNode.DimensionHierarchyLevel == dimensionHierarchyLevel.RecId
    join RangeFrom, RangeTo from dimensionConstraintNodeCriteria
        where dimensionConstraintNodeCriteria.DimensionConstraintNode == dimensionConstraintNode.RecId
    {
        setPrefix(dimensionHierarchy.Name);
        info(strFmt('%1 | %2 - %3', dimensionAttribute.Name, dimensionConstraintNodeCriteria.RangeFrom, dimensionConstraintNodeCriteria.RangeTo));
    }
}

Output

Monday, June 6, 2016

Displaying Graphs and Charts in AX Forms

This blog post will guide you, how to display data in graphs and charts in AX 2012 Forms. Sometimes you came up with requirements where end users requires graphical data on forms besides reports. In this particular post I will use an example where I will be displaying the customer details whose invoice amount is greater than $10000 and less than $20000.

step 1:

create a new form called CustomerInvoiceAmountGraph

step 2:

add CustInvoiceJour table as datasource

step 3 : 

override init() method and class declaration method

public class FormRun extends ObjectRun
{
      Graphics    graphics;
      CustInvoiceJour custinvoiceJourGraphValues;
      Microsoft.Dynamics.AX.Framework.Client.Controls.ChartToolBar chartToolbarControl;
}

public void init()
{
    super();
    // create an runtime reference to the toolbar control
   chartToolbarControl = chartToolbarControlHost.control();
   // bind the tool bar to the chart control by passing an instance of the chart control to it
    chartToolbarControl.set_ChartControl(graphControl.control());
   this.showchart();
}

step 4:

create a new method called showchart() where your logic is placed to display the customer data
whose invoice amount is greater than 10000 and less than 20000

void showchart()
{

   // create an instance of the X++ to .NET abstraction class and bind it to the chart control

    graphics =  new Graphics();
    graphics.ManagedHostToControl(graphControl);

    // set your abstracted chart options

    graphics.create();
    graphics.parmTitle("@SYS95906");
    graphics.parmTitleXAxis("CustAccount");
    graphics.parmTitleYAxis("Amount");

    // populate the chart with data

     while select CustInvoiceJour where  CustInvoiceJour.InvoiceAmount>=10000  &&                                                  CustInvoiceJour.InvoiceAmount <=20000
    {
        graphics.loadData( CustInvoiceJour.InvoiceAccount,  ' ' , CustInvoiceJour.InvoiceAmount);
    }

    graphics.showGraph();

}

step 5:

Right click Design->New control->ManagedHost

select Microsoft.Dynamics.AX.Framework.Client.Controls.ChartToolBar

step 6:

Right click Design->New control->ManagedHost

select System.Windows.Forms.DataVisualization.Charting.Chart and change the name of the control as GraphControl

output:



Sunday, February 28, 2016

Writing custom message on status bar

This post will show you to write custom message on AX status bar for specific user.

Write the following code in JOB and execute it.

static void Job1(Args _args)
{
    str txtSample;

    txtSample = "XXXXXXXXXXXXXXXXXXYYYYYYYYY"; //Replace with you message

    xUserInfo::statusLine_CustomText(true);

    infolog.writeCustomStatlineItem(txtSample);
}

Output


Friday, November 27, 2015

Launching parallel SSRS reports on screen

Recently I came across a requirement where one of our customer does not want the Check transaction to take another check page, if the number of settlements marked on Payment Journal lines exceeds the number which can be accommodated in single page. They wish to launch the details of transactions on separate report in parallel to check. However, we all know that SSRS report viewer in AX is launched as Dialog in default and hence it requires some modifications in controller class in order to avoid code blocking if any parallel report dialog is launched within report DP class.

In order to get rid of Dialog functionality of SSRS report viewer, see the following code below:

Override the "dialogShow" function in controller class

protected void dialogShow()
    {
          SysOperationDialog  sysOperationDialog;
            FormRun             formRun;

                dialog.run();
                  this.dialogPostRun();
                    sysOperationDialog = dialog as SysOperationDialog;
                      formRun = sysOperationDialog.formRun();

                          formRun.detach();
                        }

                        Override the "dialogClose" function in controller class

                        protected void dialogClose()
                        {
                            //super();
                        }
                              That's all what you need :)

                              Tuesday, October 20, 2015

                              Management Reporter Roles

                              The following tables shows the roles of AX which are transformed in Management reporter when data mart synchronizes.


                              Tuesday, September 29, 2015

                              Changing report design via code SSRS

                              It is one of the normal development requirements you may came across where you want to change the report design name on the basis of some logic. The following example shows you how to achieve this.

                              The modification is done in Controller class "outputReport" method, before "super" call you need to set the updated design name based on some condition and its done.

                              /// <summary>
                              ///    Executes the report for the print management setting that is currently loaded.
                              /// </summary>
                              /// <remarks>
                              ///    The <c>outReports</c> method loops over print management settings and calls this method for each
                              ///    print management setting loaded.
                              /// </remarks>
                              /// <exception cref="M:Exception::Error">
                              ///    The print management object has not been initialized.
                              /// </exception>
                              public void outputReport()
                              {
                                  reportDesign = 'MyReport.Report_DesignA';
                                  this.parmReportName(reportDesign);
                                  this.parmReportContract().parmReportName(reportDesign);
                                  formLetterReport.parmReportRun().settingDetail().parmReportFormatName(reportDesign);
                                  super();
                              }

                              Tuesday, September 22, 2015

                              Restoring missing DirPartyLocation info

                              I came into issue on one of the environment where somehow records of Vendor Contacts data was deleted from DirPartyLocation table and we need to restore the data without backup database as the backup database was way old to recover.

                              By looking into GAB framework which was introduced in AX 2012, I come to know that DirPartyTable  maintains Primary contacts and address information in the following fields.

                              • PrimaryAddressLocation
                              • PrimaryContactEmail
                              • PrimaryContactFax
                              • PrimaryContactPhone
                              • PrimaryContactTelex
                              • PrimaryContactURL