Walkthrough: Creating a Secondary List Page
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.
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
-
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.
-
Right-click CopyOfCustTableListPage, and then click Properties. The properties window opens and displays the properties for the query.
-
In the properties window, enter CustTableCreditLimitListPage for the Name property.
-
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.
-
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
-
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
-
In the AOT, right-click the Classes, and then click New Class. A new class is added to the Classes node in the AOT.
-
Click the new class. In the properties window, enter CustTableCreditLimitListPage for the Name property.
-
Right-click the CustTableCreditLimitListPage class, point to Override Method, and then click new. The code editor window opens and displays the following.
void new() { } -
Replace void new() with the following method signature.
static void main(Args args)
-
Add a FormRun object to the main method.
FormRun creditLimitForm;
-
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);
-
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);
-
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);
-
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
-
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.
-
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
-
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
-
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.
-
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
-
Close the properties window.
-
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.