Name is Anant Dubey and the intent to create this blog is to discuss the problems and issues that developer face in the dynamics AX development and to share the new things that come up with the new version of AX.

Friday, 27 February 2015

List Page Interaction Class and Methods in ax 2012

Listpage interaction class and methods

Interaction class of list pages extends SysListPageInteractionBase class. Some handful methods of this class are as follows:
. initializing: Called when the form is initializing – Similar to the form init method
. intializeQuery: Also called when the form is initializing – Similar to the datasource init method
. selectionChanged: Called when the active record changes – Similar to the datasource active method.
. setButtonEnabled: Should be overridden to dynamically enable/disable buttons based on the current selection. This is called from the selectionChanged method.
. setButtonVisibility: Should be overridden to show/hide buttons when the form first opens. This is used more to do a one-off layout adjustment based on system configuration/parameters, as well as the menu-item used to open the form. eg If you have a menu-item that opens a form based on status, you may want to hide the relevant ‘status’ field to reduce clutter.
List Pages in AX 2012
Scenario: Add a few fields or buttons to a list page and making it visible/invisible depending on certain conditions. No more possible by writing code on the same form since addition of methods is no more possible in case of LIST PAGES.
We have an interaction class for all the list pages. Taking the example of form -> SalesTableListPage for which the interaction class is -> SalesTableListPageInteraction.

In this class, we have 2 methods:
setButtonVisibility() - To set the buttons visible/invisible
setGridFieldVisibility() - To set the fields visible/invisible

To make a button visible/invisible, we can write below code:
this.listPage().actionPaneControlVisible(formControlStr(SalesTableListPage, NewGroup),false);

To make a field visible/invisible, we can write below code:this.listPage().listPageFieldVisible(formControlStr, (SalesTableListPage,SalesTable_lftCostHoldReasonCode),false);

AX2012 List Pages - Performance Improvementss

I’ve been working on some performance issues recently, and some of these were related to list page performance in AX 2012. The problem is that for some of the list pages, even with CU3, the main query performance is slow due to the fact that the query parameter OPTION(FAST) is not being added automatically to the SQL statement, as it does with most standard forms in Dynamics AX. For some customers this does not create a performance problem, but others may experience slowness opening the list-pages due to their data constellation. I’ve identified some of the list pages where this could be a problem, see the workaround notes below:
Vendor List Page
Object: Query > VendTableListPage > Data Sources > VendTable
Change the “FirstFast” property on the “VendTable” in this view to “Yes”.
Sales Table List Page
Object: Query > SalesTableListPage > Data Sources > SalesTable
Change the “FirstFast” property on the “SalesTable” in this view to “Yes”.
Released Product List Page
Object: Query > EcoResProductPerCompanyListPage > Data Sources > InventTable
Change the “FirstFast” property on the “InventTable” in this view to “Yes”.
Main Accounts List Page
Object: Query > MainAccountsListPage > Data Sources > MainAccount
Change the “FirstFast” property on the “MainAccount” in this view to “Yes”.
CustTable List Page
Object: Query > MainAccountsListPage > Data Sources > CustTable
Change the “FirstFast” property on the “CustTable” in this view to “Yes”.
Ledger Trial Balance List Page
Object: Query > LedgerTrialBalanceListPage > Data Sources > DimAttrvalueCombo
Change the “FirstFast” property on the “DimAttrvalueCombo” in this view to “Yes”.
public void init()
    FormRun                 callerForm;
    FormDataSource          formDataSource;

    MultiSelectionHelper    multiSelectionHelper;
    MultiSelectionContext   multiSelectionContext;

    ProjTable       projTable;


    if (!element.args().caller())
        throw error("@SYS22539");

// ************** The standard way of doing it in Dynamics AX 4 and Dynamics AX 2009 **************
    callerForm = element.args().caller();
    formDataSource = callerForm.dataSource();

    ListView.add("Approach 1");

    for(projTable = formDataSource.getFirst(1); projTable; projTable = formDataSource.getNext())
        ListView.add(strFmt("%1 - %2",projTable.ProjId, projTable.Name));

// ************** Using the new MultiSelectionHelper class in Dynamics AX 2012 **************
    multiSelectionHelper = MultiSelectionHelper::createFromCaller(element.args().caller());

    projTable = multiSelectionHelper.getFirst();
    ListView.add("Approach 2");

    while (projTable)
        ListView.add(strFmt("%1 - %2",projTable.ProjId, projTable.Name));
        projTable = multiSelectionHelper.getNext();

// ************** Using the new MultiSelectionContext class in Dynamics AX 2012 **************
    multiSelectionContext = element.args().multiSelectionContext();

    projTable = multiSelectionContext.getFirst();
    ListView.add("Approach 3");

    while (projTable)
        ListView.add(strFmt("%1 - %2",projTable.ProjId, projTable.Name));
        projTable = multiSelectionContext.getNext();

    if (!ListView.getCount())
        throw error("No projects selected");

Ax client forms can easily be published to enterprise portal by the new feature from the Menu item >> Deploy to EP.
Let me help with an example:
Create a new List Page by using the template option provided in AX 2012 as shown below and name it as SR_EcoProductListPage as shown below
List page
Change the Name of the newly created list page to SR_EcoProductListPage as shown below.
Now, let us use the query property on the data sources property to get the linked data sources from the query
Right click on the Data sources Node >> properties >> set the query property to ecoResProductListPage as shown below
DS Query
Next, Go to Design Node >> and give the caption, title data source as shown below.
Next, On the grid set the data source as EcoResProduct as shown below.

Drag and drop some fields on to grid from the Data sources >> EcoResProduct. I have dragged and droppedDisplayProductNumber and ProductType fields on to grid as shown below.

No comments:

Post a Comment