This topic has not yet been rated - Rate this topic

Walkthrough: Creating a Secondary List Page

Dynamics AX 2009

A Microsoft Dynamics AXsecondary list page displays a subset of records from an existing primary list page. To demonstrate the steps to create a secondary list page, this walkthrough uses the Application Object Tree (AOT) to build a secondary list page based on the Customers primary list page. The secondary list page displays customers who have a credit limit.

This walkthrough illustrates the following tasks:

  • Creating a secondary list page query that is based on the data source of the primary list page.

  • Creating a class that combines the Customers primary list page with the secondary list page query.

  • Creating a menu item for the class.

  • Adding the menu item to the Customers submenu in the Navigation Pane.

To complete this walkthrough, you will need:

  • Microsoft Dynamics AX.

  • A license file that includes access to the MorphX development environment.

  • Sample data in the CustTable database table of a company you can access.

In this section, you will create a query that retrieves customers who have a credit limit more than zero. The new query modifies the query the Customers list page uses as its data source.

To create a query

  1. In the AOT, expand the Queries node, right-click CustTableListPage, and then click Duplicate. A new query named CopyOfCustTableListPage is added to the Queries node in the AOT.

  2. Right-click CopyOfCustTableListPage, and then click Properties. The properties window opens and displays the properties for the query.

  3. In the properties window, enter CustTableCreditLimitListPage for the Name property.

  4. Expand the new CustTableCreditLimitListPage query, expand Data Sources, expand CustTable, right-click Ranges, and then click New Range. A range node is added to the query in the AOT.

  5. Click the new range node to display its properties in the properties window. Set the specified values for the following properties.

    Property

    Value

    Field

    CreditMax

    Value

    >0

  6. In the AOT, right-click the CustTableCreditLimitListPage query, and then click Save.

The CustTableCreditLimitListPage query retrieves customers where the value in the credit limit field is more than zero.

Next, you will use a class to replace the data source query of the Customers list page with the query that you created earlier. This class produces the secondary list page that the client displays.

To create a class

  1. In the AOT, right-click the Classes, and then click New Class. A new class is added to the Classes node in the AOT.

  2. Click the new class. In the properties window, enter CustTableCreditLimitListPage for the Name property.

  3. Right-click the CustTableCreditLimitListPage class, point to Override Method, and then click new. The code editor window opens and displays the following.

    void new()
    {
    }
    
  4. Replace void new() with the following method signature.

    static void main(Args args)
    
  5. Add a FormRun object to the main method.

    FormRun creditLimitForm;
    
  6. Use the SysListPageHelper class to generate the form. For parameters, specify the primary list page name, the name of the query that you created earlier, a string that identifies this list page, and the args parameter of the main method. For more information about the runFormWithModeledQuery method, see SysListPageHelper Class.

    creditLimitForm = SysListPageHelper::runFormWithModeledQuery(
      formstr(CustTableListPage),
      querystr(CustTableCreditLimitListPage),
      "Sample Secondary List Page",
      args);
    
  7. To display the value in the credit limit field, add the following code to the main method.

    creditLimitForm
      .design()
      .controlName(identifierstr(CustTable_CreditMax))
      .visible(true);
    
  8. To hide fields that do not have to be displayed, add the following code to the main method.

    creditLimitForm.design().controlName(identifierstr(CustTable_Phone))
      .visible(false);
    creditLimitForm.design().controlName(identifierstr(CustTable_PhoneLocal))
      .visible(false);
    creditLimitForm.design().controlName(identifierstr(ContactPerson_Name))
      .visible(false);
    
  9. To validate and save all your code changes, click the Compile button in the code editor window. Close the code editor window.

The CustTableCreditLimitListPage class produces a list page that displays customers who have credit limits more than zero. To view the list page, you have to instantiate and run the class. The following sections describe how to make this secondary list page available.

Next, you will create a menu item for the CustTableCreditLimitListPage class that you created earlier. The menu item enables you to add the class that produces the secondary list page to the Navigation Pane of the client.

To create a menu item

  1. In the AOT, expand the Menu Items, right-click Display, and then click New Menu Item. A new menu item is added to the Display node in the AOT.

  2. Click the new menu item to display the properties of the menu item in the properties window. Set the specified values for the following properties.

    Property

    Value

    Label

    Customers with Credit Limits

    Name

    CustTableCreditLimitListPage

    Object

    CustTableCreditLimitListPage

    ObjectType

    Class

  3. In the AOT, right-click the CustTableCreditLimitListPage menu item, and then click Save.

When this menu item is selected, it uses the class specified by the Object property to display the secondary list page. For more information about menu items, see MenuItem Class.

In this section, you will add the CustTableCreditLimitListPage menu item to the Customers submenu. This adds the menu item to the Navigation Pane.

To add the menu item to the Navigation Pane

  1. In the AOT, expand the Menus node, expand Cust, right-click Customers, point to New, and then click Menu Item. A new menu item is added to the Customers node in the AOT.

  2. Click the new menu item to display the properties of the menu item in the properties window. Set the specified values for the following properties.

    Property

    Value

    MenuItemName

    CustTableCreditLimitListPage

    IsDisplayedInContentArea

    Yes

  3. Close the properties window.

  4. In the AOT, right-click the Cust menu, and then click Save

To view the secondary list page, you must restart the Microsoft Dynamics AX client. In the Navigation Pane, open the Account receivable module. In the Places group, expand Customers. You should see Customers with Credit Limits as a new list page option. Click Customers with Credit Limits to display the secondary list page in the content pane of the client. For more information about the menu, see Menu Class.

Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.