Walkthrough: Adding a Field to a User Control
Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012
Enterprise Portal contains numerous entity overview pages that display detailed data for specific items in Microsoft Dynamics AX. For example, the View customer page displays detailed information about a customer. A User Control displayed in a User Control web part is used to display the data on the page. The AxForm is the main component of the User Control used for the View customer page.
A common customization is adding or changing the fields that are displayed in an entity overview page. This walkthrough demonstrates how to add a field to the first group that appears on the View customer entity overview page. It illustrates the following tasks:
Determining the User Control to modify.
Creating an EP Web Application project.
Adding a User Control to the EP Web Application project.
Modifying a User Control.
Viewing the customization in Enterprise Portal.
To complete this walkthrough, you will need:
Microsoft Dynamics AX
Visual Studio 2010
Visual Studio Tools from the Microsoft Dynamics AX installation
Enterprise Portal Administrator status
Determining the User Control to Modify
Before you can modify the fields displayed on the View customer page, you must determine which User Control is being used for that page.
To determine the User Control to modify
Using a web browser, open Enterprise Portal. The typical URL to access Enterprise Portal is:
Substitute the name of the server on which Enterprise Portal is installed.
Display the All Customers list page. Click Sales on the top link bar. Select one of the customers in the list, and then click View. The View customer page with customer information is displayed.
In the ribbon, display the Page tab.
Click the Edit Page command.
Locate the View customer web part in the middle column. In the drop-down menu for this web part, click Edit Web Part. The drop-down menu is the small arrow found on the upper-right corner of the web part.
In the list of properties for the web part, locate the Managed content item property. It is set to CustomerOverview, which is the User Control that is being displayed in the web part. This is the User Control that will be modified.
Click Cancel to close the list of web part properties.
Click Stop Editing to return to the View customer page. Close the page.
Creating the EP Web Application Project
Visual Studio is used to modify User Controls for Enterprise Portal.
To create the EP Web Application project
Start Visual Studio. If User Account Control (UAC) is active, make sure you start Visual Studio with administrative privileges. To do this, right-click the shortcut for Visual Studio and then click Run as administrator.
In the File menu, click New, and then click Project.
In the New Project window, select .NET Framework 3.5 as the framework version to use.
For this release of Microsoft Dynamics AX, the EP Web Application project must target the .NET Framework 3.5 to work correctly.
In the Installed Templates list, select Microsoft Dynamics AX. If you do not see this project template, make sure that you have Visual Studio Tools for Microsoft Dynamics AX installed.
Choose the EP Web Application template.
Specify a name for the project, and the location of the folder where you want to store the files for the project.
Click OK to create the project.
Adding the User Control to the EP Web Application Project
You must add the User Control to the EP Web Application project so that you can modify the User Control's properties.
To add the User Control to the EP Web Application project
In the View menu in Visual Studio, click Application Explorer.
In the Application Explorer, expand the Web > Web Files > Web Controls node.
In the Web Controls list, locate the CustomerOverview control.
Right-click the CustomerOverview control, and then click Add to project. The control and several related controls are added to the project.
Close the Application Explorer.
Modifying the User Control
Use Visual Studio to make changes to the User Control.
To modify the User Control
Locate the CustomerOverview.ascx component in Solution Explorer.
Right-click the CustomerOverview component in Solution Explorer, and then click View Designer.
After a few moments, you will see several components in the control layout. The AxDataSource component is used to access data for the customer overview page. The AxMultiSection component contains all of the expandable sections that you see in the View customer page. The sections contain AxGroup components, which are used to display fields.
Click the Customer AxGroup component directly in the layout to select it. This component contains the fields that are displayed at the top of the General section of the View customer page.
To modify the fields that are displayed in the group, use one of the following methods:
Display the context menu at the upper-right corner of the AxGroup control in the layout. Click Edit Fields to display the Bound Field Designer.
Locate the Fields property in the Properties list. Click the ellipsis button to display the Bound Field Designer.
The Selected Field list contains the fields that appear in the group. Only the AccountNum field is included. In the Available Fields list, select the OrderEntryDeadlineGroupId field. Click Add Field to add this field to the list of fields that will be displayed in the group.
Make sure that the OrderEntryDeadlineGroupId field is selected in the Selected Field list.
In the BoundField Properties list, locate the HeaderText property. Set the value of this property to Order entry deadline:.
Click OK to save the changes to the list of fields for the AxGroup.
In the File menu, click Save CustomerOverview.ascx to save the changes you made to the User Control. The changes are exported automatically to the AOT. The updated User Control is also deployed to the Enterprise Portal server.
Viewing the Customization in Enterprise Portal
After the field has been added to the User Control, you can view it in Enterprise Portal.
To view the customization in Enterprise Portal
Using a web browser, open Enterprise Portal.
Click Sales on the top link bar. Display the All Customers list page. Select one of the customers in the list, and then click View. The View customer page with the customer information is displayed. You will see the customer details, including the Order entry deadline field that you added.
To learn more about User Controls in Enterprise Portal, see User Controls Overview.