Wednesday, May 14, 2014

Set Value On a Control in List Page through ListPage Interaction class (Dynamics AX 2012)

I recently had a requirement to display sum of total volume (a display method) of all the selected records on a List page form. There were two major development tasks in this requirement

  1. To loop through all records that user has selected on List Page.
  2. To set value on a custom control of List Page after calculation.
You can easily loop through list of selected records with in interaction class by using MultiSelectionHelper class. However, I found it a bit tricky in setting up the control value of List page as previously I only used this class to enable/disable or make visible true false of controls or buttons on list page.

Here is the code for your reference if you ever need to do the same.
For sure there will be many other more effective ways of doing this. If you ever had to do and know the best way please share with me as well.

protected void setSumOfTotalVolume()
{
    ReqPO               reqPO;
    Volume              totalVolume;
    Common              externalRecord;
    FormDataSource      frmDs;
    FormRun             formRun;
    FormRealControl     frmCtrl;
    MultiSelectionHelper helper = MultiSelectionHelper::construct();

    helper.parmDatasource(this.listPage().activeRecord('ReqPO').dataSource());

    reqPO = helper.getFirst();
    while (reqPO.RecId != 0)
    {
        totalVolume += reqPO.totalVolume();
        reqPO = helper.getNext();
    }

    //Assign value to control on list page
    externalRecord = this.listPage().activeRecord('ReqPO');

    if(externalRecord.isFormDataSource())
    {
        frmDs   = externalRecord.dataSource();
        formRun = frmDs.formRun();
        if(formRun)
        {
            frmCtrl = formRun.design().controlName(formControlStr(ReqTransPOListPage,TotalVolumeField));
            if(frmCtrl)
            {
                frmCtrl.realValue(totalVolume);
            }
        }
    }
}

You should also call this method from interactionclass.selectionchanged() method to update value on every record selection.

Hope it will be help full for if you have a similar requirement in future.

Happy DAXing !!

Sunday, July 29, 2012

How to get onhand inventory?

A very common practice for a developer on day to day basis is to get on hand inventory based on different parameters (dimensions). I’ve came across a situation where I was getting this physical available from ‘InventSum’ table directly rather using ‘InventOnhand’ class and the result was different for some items. I think it would be better to use the InventOnHand class for querying on hand data. AX uses a secondary table called ‘InventSumDelta’ for capturing changes applied to the ‘inventSum’ that haven’t been committed yet. Not taking the ‘InventSumDelta’ in consideration can lead to unexpected results.
Here is the sample code snippet you can use for this purpose

Sunday, March 4, 2012

Data Import: Using Excel Add-in


While looking up some issues in data import functionality of Dynamics AX 2012, I came across an extremely useful blog. This blog is being maintained by Alex Anikiev. You will find a series of blog posts on importing data into AX 2012 using the Excel add-ins. He listed all the steps necessary to fix issues you might face when using Excel add-in.

I myself found this blog really very helpfull in getting understanding and resolving my issues.

Following articles can be of common interest when loading beginning balances.

Monday, January 30, 2012

Label files (Import and Delete) In Dynamics AX 2012

Today, I’m going to explore how can we import and delete label files in Dynamics AX 2012. Labels are no longer a file system like we had in 2009. We now have a new node in AOT - Label Files
To import labels that is exported from some other system right click on the Label Files node and select Create from File. Browse and select your .ald file. Once you select the file and hit OK, a new node is added under the Label Files node corresponding to the label file imported.
The amazing thing in 2012 is that you don’t need to restart AOS to re-build index files that we were doing in AX 2009. Just try using the label somewhere and you will see that it is immediately referenced.

If you search in your application folder, you won’t find the label file there. The application folder is located here
C:\Program Files\Microsoft DynamicsAX\60\Server\MicrosoftDynamicsAX\bin\Application\Appl\Standard

In Dynamics AX 2012, the label file is imported in your current model.

One of the important things to note is that if you right click on your label file you will not see a delete/remove option. In order to delete label file we have to transfer this file to a temporary Model and then we will delete the model by stopping AOS. Let’s do step by step



When you open AX now, you will get a dialog saying that "Your model store has been modified." This is normal because each time you perform an operation on a model, you will get this dialog. Depending on your operation, you should select one of the options. Since we just deleted a model which just had a label file, select Skip.
Open AOT and notice that the label file is deleted now.

Tuesday, January 17, 2012

Filter Dynamics AX lookup on EP 2012


Today, I came accross a requirement to filter AX lookup in EP 2012. I am making a web control where i need to display filtered lookup. I was thinking to modify performFormLookup() method on dataset datsource field. However, it didn't work.

The trick is to override datasetLookup() on Dataset > data source > field > methods. You will not find this method in the list of override methods so just create this as new method.





Monday, January 16, 2012

SSRS report in EP based on user selection

In this post, I will be explaining how to display SSRS report to Enterprise portal based on user input. The example which we will be following has a scenario to display pay slip report for each employee. The requirement can be that each employee should see his pay slip for any month based on selection. It means we have to pass two parameters i.e. the user logged in and the date he selected for the pay slip or with one parameter to filter query based on worker logged in.

To achieve this we have to do following steps

1.      Create SSRS report using data provider class and deploy it on server .

2.      Create DataContractor class to add a parameter which implements  SysOperationInitializable and SysOperationValidatable interfaces.

3.      Create a data provider class which will be filling temporary table on the basis of parameters passed through contractor class.

4.      Create a EP page which contains date calendar and a reportviewer control. We will be rendering report based on selected date.
[Note: Code written for classes is just for reference. It depends on the table and query as per your criteria. I am simply pasting code which is specific for my case. Do modify it as per your AOT structure.]

Now let’s see the detail.


Contractor class:


Data Provider class:




Now this is what we required to do in Dynamics AX. Let’s just see the modifications required on Visual studio EP project.
Web Control:


Add a web control to an EP project and then add following two controls

·         Calendar

·         AXReportViewer


 
Now, to render the report we will set the user selected date and on the event of selection change we will render the report as shown


I hope you will find this post helpful. In case of any question or help in this regard you are welcome.

Happy Daxing J

Tuesday, January 10, 2012

EP Development in Dynamics AX 2012

Enterprise Portal is a combination of several standard Microsoft technologies that extend a similar user interface to that available in the Microsoft Dynamics AX 2012 client.
Till AX 2009, developing an application/form for EP was not that much simple. Along with some other enhanced features introduced in 2012, Microsoft has made a tremandous change in this area as well.
For an example, If you made a List page form in Dynamics AX client then you can easily deploy this form on Web with just one click.

Recently, I developed my new module on EP and have developed a leave request form for the employee that is enabled for Workflow as well. I found the following video very helpfull. This is basically an internal training given by one of my friend named Zeeshan Jafery. 
http://vimeo.com/26902748