Chapter 7. Enterprise Portal

The objectives of this chapter are to:

  • Introduce Enterprise Portal.

  • Highlight new features in Microsoft Dynamics AX 2009 Enterprise Portal.

  • Provide insight into the ASP.NET Enterprise Portal Web framework design and runtime components.

  • Illustrate the integration of the Application Object Tree (AOT), Microsoft Visual Studio, and Windows SharePoint Services.

  • Offer a detailed look at Enterprise Portal security.

This chapter explores the Enterprise Portal framework, from the concepts on which it is based to its inner workings. Both Dynamics AX developers and ASP.NET Web developers can customize Web applications or build new ones easily within Enterprise Portal. This chapter covers how the Enterprise Portal framework brings Dynamics AX development into the managed world of ASP.NET and Visual Studio, allowing developers to use Dynamics AX, AJAX, and ASP.NET to leverage the Dynamics AX data and business logic programming model and use ASP.NET to build rich Web presentations with great user interfaces, interaction, and responsiveness.

Introduction

Enterprise Portal is the Web platform for Dynamics AX 2009. Using the Enterprise Portal framework, developers can create new Web applications for Dynamics AX or customize existing ones. Enterprise Portal enables customers, vendors, business partners, and employees to directly access relevant business information and collaborate and conduct business transactions from anywhere through an easy-to-use Web user interface.

Enterprise Portal enables organizations to extend and expand the use of enterprise resource planning (ERP) software and reach out to customers, vendors, business partners, and employees and access business applications from anywhere. By allowing them to interact directly with the business system, Enterprise Portal improves customer satisfaction, reduces support and help desk calls, empowers employees to collaborate effectively and make informed decisions, and improves overall efficiency.

Users access Enterprise Portal through a Web browser remotely or from within a corporate intranet, depending on how Enterprise Portal is configured and deployed. Enterprise Portal contains a set of default Web pages and user roles that you can use as-is or modify to meet your customer’s unique business needs. Enterprise Portal serves as the central place for users to access any data, structured or unstructured, such as transactional data, reports, charts, key performance indicators (KPIs), documents, and alerts. They can access and collaborate on this data from anywhere. Figure 7-1 shows the home page of an Enterprise Portal site.

Example of an Enterprise Portal home page

Figure 7-1. Example of an Enterprise Portal home page

Inside Enterprise Portal

Built on ASP.NET and Windows SharePoint Services products and technologies, Enterprise Portal combines all the rich content and collaboration functionality in Windows SharePoint Services with the structured business data in Dynamics AX. It also brings the power and flexibility of ASP.NET and Visual Studio to help you build responsive, modern Web applications. This section introduces the underlying technology components that make up Enterprise Portal. In the subsequent sections, we discuss each component in detail.

With the rich Dynamics AX programming model, Enterprise Portal defines data access and business logic in MorphX, similar to the desktop client. It exposes data and business logic through data binding, data and metadata APIs, and proxy classes to ASP.NET, and it uses ASP.NET to define the user interface. Enterprise Portal uses the Web Part page framework from Windows SharePoint Services to build Web pages that allow easy customization and personalization. Enterprise Portal also brings the best of Dynamics AX, ASP.NET, and Windows SharePoint Services together and unifies them in the Application Object Tree (AOT) for easy deployment.

Developers define the business logic and data access in MorphX and use Visual Studio to build Web User Controls and define the Web user interface elements. Within the Web User Control, they can use Enterprise Portal controls or any ASP.NET control and use data binding and the standard ASP.NET programming model to define the user interface logic, seamlessly leveraging the business logic defined in MorphX and accessing Dynamics AX metadata and business data.

Developers use Windows SharePoint Services to define Web pages. Enterprise Portal Web pages use Enterprise Portal Web parts and other Windows SharePoint Services or Microsoft Office SharePoint Server (MOSS) Web parts. The Enterprise Portal Web parts present information and expose functionality from Dynamics AX and are implemented with Windows SharePoint Services Web part technology. One such Web part is the Dynamics User Control Web part, which can host any ASP.NET Web User Control and connect to Dynamics AX through the Enterprise Portal framework and the .NET Business Connector. Windows SharePoint Services Web parts fulfill content and collaboration needs. Figure 7-2 shows the high-level components of Enterprise Portal.

Enterprise Portal components

Figure 7-2. Enterprise Portal components

Page Processing

The first step in developing or customizing an application on Enterprise Portal is to understand the interactions between the user’s browser on the client and Enterprise Portal on the server when the user accesses Enterprise Portal. The following sequence of interactions occurs when a user accesses Enterprise Portal:

  1. The user opens the browser on his or her machine and navigates to Enterprise Portal.

  2. The browser establishes a connection with the Internet Information Services (IIS) Web server.

  3. Based on the authentication mode enabled, IIS authenticates the user.

  4. After the user is authenticated, the Windows SharePoint Services Internet Server Application Programming Interface (ISAPI) filter intercepts the page request and checks the user’s right to access the site.

  5. After the user is authorized by Windows SharePoint Services, the Web page routes to a custom Microsoft ASP.NET page handler object of Windows SharePoint Services.

    Figure 7-3 shows a simplified version of the page request process.

    Page request flow in Enterprise Portal

    Figure 7-3. Page request flow in Enterprise Portal

  6. The page handler pulls the Web part page data from the Windows SharePoint Services content database. This data contains information such as the page template ID, the Web parts used and their properties, and the page template stored on the file system on the Web server. Windows SharePoint Services then processes the page and creates and initializes the Web parts on the page with any properties and personalization data.

  7. When initialing Enterprise Portal Web parts, Enterprise Portal initializes a Web session with the Enterprise Portal Web framework through the .NET Business Connector to the Application Object Server (AOS).

  8. The Web framework checks for Dynamics AX authorization and then calls the appropriate Web handlers in the Web framework to process the Enterprise Portal objects that the Web part points to.

  9. The Dynamics User Control Web part runs the Web User Control that it’s pointing to. The Web User Control connects to Dynamics AX through .NET Business Connector and renders the HTML to the Web part.

  10. The Web page assembles all the HTML returned by all the Web parts and renders the page to the user’s browser.

  11. The Enterprise Portal Web session ends.

As you can see in this sequence, the AOS processes all the business logic and data retrieval, ASP.NET processes the user interface elements, and Windows SharePoint Services handles the overall page layout and personalization.

New Features in Dynamics AX 2009 Enterprise Portal

Microsoft Dynamics AX 2009 EP provides many new features to empower developers to build and customize rich Web user interface that enables end users to find and access business information quickly and efficiently. Here is a list of high-level Enterprise Portal features introduced in Dynamics AX 2009.

  • New Web framework for supporting ASP.NET-based Web user interface

  • Visual Studio add-in for Web development and integration to the AOT

  • ASP.NET controls for common user interface elements

  • Use of AJAX for rich user interactions

  • Web parts for common page elements

  • AOT nodes for storing and securing components for the new Web framework

  • A single site for all Dynamics AX companies similar to the client and the ability to switch companies through the company switcher

  • Context-specific Help for Enterprise Portal

  • Top and left navigation providers for integrating navigation elements in Windows SharePoint Services with business application navigation defined in the AOT

  • Modules created as subsites for easy management

  • Consistent navigation for Web modules in Quick Launch

  • New applications: CRM in Sales Module, Expense Management, Purchase Requisition, Service Management, Compliance Center

  • Role Centers in the client and in Enterprise Portal

  • Migration of all out-of-the-box pages to the new ASP.NET framework

  • Enterprise Portal deployment completely automated and integrated with Dynamics AX setup

  • In-place upgrade from Windows SharePoint Services 3.0 and Microsoft Office SharePoint Server (MOSS) 2007 sites to Dynamics AX 2009 Enterprise Portal sites

Enterprise Portal Development Tools

You develop the data and business tier components of Enterprise Portal using MorphX, the integrated development environment (IDE) in Dynamics AX. You define navigation and site hierarchy in MorphX. You develop the presentation tier components in Visual Studio and design the Web page using Windows SharePoint Services. AOT serves as the single master of all metadata for Enterprise Portal. It stores all the controls and pages you developed using Visual Studio and Windows SharePoint Services, and other supporting files, definitions, and features, under the Web node.

MorphX

MorphX is used for developing and debugging data and business tier components, defining navigation elements, storing unified metadata and files, importing and deploying controls, storing page and list definitions, and generating proxies.

For Enterprise Portal data access purposes, the new programmable object Data Sets is added to the AOT. Data Sets in Enterprise Portal are equivalent to the Form data source for the Desktop form. You can create Data Sets with one or more joined data sources pointing to related tables in Dynamics AX. You can override or add new methods in data sets, data sources, and tables as well as define the data access logic.

You generally define the business logic in classes in the AOT. These classes are referenced either in the data set or through C# proxy classes in the presentation components in Enterprise Portal.

You can generate proxy classes either from Visual Studio or from MorphX (ToolsDevelopment ToolsWeb DevelopmentProxies). The tables and classes from which proxy files need to be generated are defined in AOTWebWeb FilesStatic FilesProxies. Web-related components are stored under AOTWeb.

The Web User Controls for the presentation tier that you develop in Visual Studio are added to the AOT under AOTWebWeb FilesWeb Controls. These controls are referenced and secured by AOTWeb ContentManaged Nodes. The Visual Studio add-in for Dynamics AX lets you add the controls from Visual Studio to the AOT directly.

Static files that Enterprise Portal uses, such as style sheets, configuration files, and aspx files, are kept under AOTWeb FilesStatic Files. Images and resources are kept at AOTResources.

The pages and lists you create in Windows SharePoint Services are exported to the AOT and stored under AOTWebWeb FilesPage Definitions and AOTWebWeb FilesList Definitions.

Enterprise Portal Web parts site definitions are kept under AOTWebWeb FilesWeb Parts and AOTWebWeb FilesSite Definitions. The Site Templates node is for any customized Windows SharePoint Services templates.

For Web sites, consistent navigation is important for users to perform their tasks quickly and easily. Site navigation in Enterprise Portal consists of a global menu bar that is displayed at the top of the site, the module-level QuickLaunch navigation, which is on the left side, and toolbars that are inside the page.

Web modules define the site hierarchy and the top-level navigation. Web menus define the menu hierarchy used by the Dynamics QuickLaunch Web part or the toolbar. Web menu items that point to the page or class are used in Web menus.

Visual Studio

You develop and debug presentation-tier components in Visual Studio. The Visual Studio add-in for Enterprise Portal provides a project and control template for Web user interface development. You define all the user interface logic in Web User Controls using Enterprise Portal development tools, and you use the Enterprise Portal framework to access data and metadata for ASP.NET controls. The Visual Studio add-in also provides an easy way to add controls to the AOT, import controls or style sheets from the AOT, and generate proxies. It also provides a test page for previewing the user interface and debugging.

Windows SharePoint Services

You use Windows SharePoint Services to develop Web part pages or lists and to edit master pages, which contain the common elements for all the pages. You can use the Create or Edit Page tools of Windows SharePoint Services in the browser and use one or more Enterprise Portal or any Web parts and design your Web page. You can also use the Microsoft Office SharePoint Designer 2007 tool to create or edit Web part pages or master pages.

Developing Data Sets

Data Sets is a new AOT node in Dynamics AX 2009. It is used to define the data access logic. A data set is a collection of data usually presented in tabular form. The data set brings the familiar data and programming model known from Dynamics AX forms together with ASP.NET data binding. In addition, the data set offers an extensive X++ programming model for validating and manipulating the data when creating, reading, updating, or deleting in Enterprise Portal. The AxDatasource control in ASP.NET uses data sets to display and manipulate data from any ASP.NET control that supports data binding. A data set can contain one or more data sources that are joined together. The data sources could point to a table or a view in Dynamics AX. Data sources can be joined to display data from multiple tables as a single data source. To do this, you use inner or outer joins. To display parent-child data, you use active joins. To surface data from joined data sources or from parent-child data sets, you use dynamic data set views (DataSetView). With a view-based interface, tables are accessed through dynamic data set views rather than directly. You can access inner-joined or outer-joined tables through only one view, which has the same name as the primary data source’s name. Two views are available with active-joined data sources: one with the same name as the parent data source, and another with the same name as the child data source. The child data source contains records related only to the current active record in the parent data source.

Each data set view could contain zero or more records, depending on the data. Each data set view also has a corresponding special view, which contains just the current, single active record. This view has the same name as the original view with _Current appended to the view name. Figure 7-4 shows the data set views inside a data set and the data binding.

Data set views

Figure 7-4. Data set views

Data sets offer an extensive and familiar X++ programming model for validating and manipulating data. Some of the methods you’ll be using frequently include init, run, pack, and unpack.

  • The init method is called when the data set is initialized. It is activated immediately after new and creates the run-time image of the data set. Typical uses of init include adding ranges to restrict the data, checking the arguments and parameters passed, and initializing and modifying variables and queries.

  • The run method is called after the data set is initialized and opened, and immediately after init. Typical uses of run include conditionally making fields visible or hidden, changing the access level on fields, and modifying queries.

  • The pack method is called after the data set is run. You generally use the pack/unpack pattern to save and store the state of an object, which you can later reinstantiate. A typical use of pack is to persist a variable used in the data set between postbacks.

  • The unpack method is called if a data set was previously packed and then accessed. If a data set was previously packed, init and run aren’t called. Instead, only unpack is executed.

Data sources within a data set also include a number of methods you can override. These methods are similar to those in the FormDataSource class on the Desktop. You can use them to initialize the default values and validate values and actions. For more information about these events, such as when they are executed and the common usage scenarios, refer to the "Methods on a Form Data Source" topic in the Microsoft Dynamics AX 2009 software development kit (SDK), on MSDN.

Developing Web User Interface Components

Enterprise Portal has a built-in set of ASP.NET controls you can use to access, display, and manipulate Dynamics AX data. It also includes APIs for programmatic access to data and metadata, a C# proxy class framework to access Dynamics AX business logic, and helper classes and a Visual Studio add-in for adding and importing files to and from the AOT. Figure 7-5 shows a sample Visual Studio project for Enterprise Portal development.

Enterprise Portal Visual Studio project

Figure 7-5. Enterprise Portal Visual Studio project

AxDataSource

Data sets you create in the AOT are exposed to ASP.NET through the AxDataSource control. AxDataSource abstracts the data store and the operations that can be performed on the data, from connecting to or reading/writing from the data store. You can associate ASP.NET data-bound user interface controls with AxDataSource through the DataSourceID property. Using this standard ASP.NET data binding, you can rapidly develop user interface logic without needing specific domain knowledge about how to connect to or access data from Dynamics AX. Because AxDataSource takes care of the data access from Dynamics AX, developers don’t have to worry about data access and can focus on the business aspect.

The data source control is simply a container for one or more uniquely named views (AxDataSourceView). All the logic is encapsulated in this DataSourceView-derived class. AxDataSourceView implements all the functionality to read and write data. The data-bound control can identify the set of enabled capabilities and display the right set of user interface controls and enable or disable them. You use the DataMember property of a data-bound control to select a particular view. AxDataSourceView maps to the data set view. So for each dynamic data set view based on the number of data sources and the type of join, you get an equivalent number of AxDataSourceView in the AxDataSource control to which any data-bound control can bind.

The data source control also supports filtering records within and across other data source controls and data source views. When you set the active record on the data source view within a data source control, all the child data source views are also filtered based on the active record. You can filter across data source controls through Record Context. In Record Context, one data source control acts as the provider of the context, and zero or more data source controls act as consumers. One data source can act as both provider and consumer. When the active record changes on the provider data source control, the record context is passed to other consuming data source controls, and they apply that filter as well. You use the Role and ProviderView properties of AxDataSource for this purpose. One Web User Control can contain any number of AxDataSource controls. Only one of them can have the property Role set to Provider. Any number of them can be set to Consumer.

You can use the DataSetViewRow object to access the rows in a DataSetView. The GetCurrent method returns the current row.

DataSetViewRow row = this.AxDataSource1.GetDataSourceView("View1").DataSetView.
GetCurrent();

The GetDataSet method on AxDataSourceControl specifies the data set to bind. The DataSetRun property provides the run-time instance of the data set, and you can use AxaptaObjectAdapter to call the methods. So to invoke methods defined in data sets from a Web User Control, you would use the following code.

this.AxDataSource1.GetDataSet().DataSetRun.AxaptaObjectAdapter.Call("method1");

AxGridView

The AxGridView control displays the values of a data source in a table format in which each column represents a field and each row represents a record. With AxGridView, you can select, sort, group, expand, filter, edit, and delete items. AxGridView extends the ASP.NET GridView control and lets you provide selection, grouping, expansion rows, filtering, context menus, and other enhanced capabilities within the Dynamics AX Enterprise Portal user interface.

AxGridView also includes built-in data modification capabilities. Using AxGridView with the declarative AxDataSource, you can easily configure and modify data without writing a single line of code. AxGridView also has many properties, methods, and events that you can easily customize with application-specific user interface logic.

You can find the full set of properties, methods, and events for GridView and AxGridView on MSDN. Listed here are some of the AxGridView properties you’ll likely use most often:

  • AllowDelete. If enabled and if the user has delete permission on the selected record, AxGridView displays a Delete Selected Item button and allows the user to delete the row.

  • AllowEdit. If enabled and if the user has update permission on the selected record, AxGridView displays Save and Cancel buttons on the selected row and allows the user to edit and save or cancel edits. When a row is selected, it automatically goes into edit mode, and edit controls are displayed for all columns for the selected record where the AllowEdit property for the column is set to true.

  • AllowGroupCollapse. If grouping is enabled, this setting allows the user to collapse the grouping.

  • AllowGrouping. If set to true, and a group field is specified, the rows are displayed in groups and sorted by group field. Page size is maintained, so one group might span multiple pages.

  • AllowSelection. If set to true, the user can select a row.

  • ContextMenuName. If ShowContextMenu is enabled, ContextMenuName defines the name of the Web menu in the AOT to be used as a context menu when the user right-clicks the row.

  • DisplayGroupFieldName. Gets or sets a value that indicates whether the GroupFieldName is displayed in the group header text of a group view of a GridView control. The default is true.

  • GroupFieldData field that is used to group GridView. This property is used only when AllowGrouping is set to true.

  • GroupFieldDisplayName. Display name for the group field used in the display <GroupFieldDisplayName> : <GroupFieldValue>. If a name isn’t specified, by default the label of the GroupField renders in group view. This property is used only when AllowGrouping is set to true.

  • ShowContextMenu. If set to true, displays the Web menu defined in the ContextMenuName property as the context menu when the user right-clicks the row.

  • ShowFilter. If set to true, displays the filter control in AxGridView.

  • ExpansionColumnIndexesHidden. A comma-separated list of integers, starting with 1, that represents which columns to hide from the expansion row.

  • ExpansionTooltip. The tooltip displayed on the expansion row link.

  • ShowExpansion. Specifies whether an expansion is available for each row in the grid. When set to true, the expansion row link is displayed for each row in the grid.

Figure 7-6 shows a sample list page with the filter control and context menu set.

Enterprise Portal list page with filter control and context menu

Figure 7-6. Enterprise Portal list page with filter control and context menu

ContextMenu

The ContextMenu object also allows you to add menu items and separators at run time. It provides methods to remove menu items and resolve client or Enterprise Portal URLs. You can access the ContextMenu object from AxGridview.ContextMenu.

ActionMenuItemClicked, ActionMenuItemClicking, and SetMenuItemProperties are three ContextMenu events.

SelectedIndexChanged, DataBound, and Row* events are AxGridView events for which you commonly write code to specify actions to take when the selection is changed, to inspect and change styles when data is rendered, and to react when rows are modified, respectively.

AxFilterControl

If the ShowFilter property of AxGridview is set to true, AxGridView embeds AxFilterControl. AxFilterControl is displayed at the top of AxGridView. AxFilterControl reads the metadata from the AxDataSourceControl the AxGridView is binding to and displays controls dynamically to allow the user to filter the data source with any of its field that are not hidden or locked. You can access the filter control through the AxGridView FilterControl property and the filter XML through Filter.

The filter control sets the filter on AxDataSetView using AxDataSourceView, which is responsible for keeping the data in sync with the filter set by calling SetAsChanged and ExecuteQuery if data has changed. AxDataSourceView and DataSetView expose the SystemFilter and UserFilter properties and the ResetUserFilter method APIs for the filter control to set the filter programmatically.

For example, you can set the range in the data set in X++ as follows.

qbrBlocked = qbds.addRange(fieldnum(CustTable,Blocked));qbrBlocked.value(queryValue-
(CustVendorBlocked::No));qbrBlocked.status(RangeStatus::Hidden);

In the Web User Control, you can read the SystemFilter set on the data source.

this.AxDataSource1.GetDataSourceView(this.AxGridView1.DataMember).SystemFilter.ToXml()

or

this.AxDataSource1.GetDataSet().DataSetViews[this.AxGridView1.DataMember].
SystemFilter.ToXml();

returns

<?xml version="1.0" encoding="utf-16"?><filter xmlns:xsi="http://www.w3.org/2001/
XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="CustTable">-
<condition attribute="Blocked" operator="eq" value="No" status="hidden" /></filter>

DataSourceView and DataSetView have the following methods, which allow you to read the different types of filters and reset them.

  • SystemFilter gets the complete list of ranges on the query, including open, hidden, and locked, into the conditionCollection on the filter object.

  • UserFilter gets only the open ranges on the QueryRun into the conditionCollection on the filter object.

  • ResetFilter method clears the filter set on the QueryRun and thus resets to the filter (ranges) set programmatically.

Here is a code snippet to set the filter programmatically.

this.AxDataSource1.GetDataSourceView(this.AxGridView1.DataMember).SystemFilter.AddXml-
(@"<filter name='CustTable'><condition attribute='CustGroup' status='open' value='10'
operator='eq' /></filter>");

AxForm

AxForm displays a single record from a data source, where each data row represents a field in the record. The first column in the row often displays the name of the field, and the second column displays the value of the field for the record. The AxForm control allows you to view, create, and update a single record.

AxForm is a data-bound control with built-in data modification capabilities. When you use AxForm with the declarative AxDataSource control, you can easily configure it to display and modify data without needing to write any code. It also provides a rich set of properties, methods, and events you can customize with application-specific user interface logic.

The DataSourceID, DataMember, and DataKeyNames properties define the data-binding capabilities of the AxForm control. AxForm also provides properties to autogenerate action buttons, setting their text and the mode. You set the UpdateOnPostback property if you want the record cursor to be updated at post back so that other controls can read the change. AxForm also provides events for all the actions that can be taken on the form before and after that action is completed. You can write code in these events for user interface or application-specific logic before or after the action is completed.

The AxForm control is a container for a collection of controls. If your form contains many fields and requires visually grouping the related fields, allowing them to be expanded or collapsed, you use the AxMultiSection control inside the AxForm control. If your form is simple and has only a few fields, you can use the AxGroup control.

AxMultiSection

AxMultiSection allows you to define a collection of AxSection controls, where each AxSection control contains child controls. By default, all sections are in expanded mode and rendered vertically, one after the other. Users can keep any number of them in expanded or collapsed mode. You can also configure AxMultiSection so that only one section is expanded at any point. In this mode, expanding a second section causes the first one to collapse, keeping just one section active. Set the ActiveMode property to true to enable that behavior. You use the ActiveSectionIndex property to get or set the active section. The AxMultiSection component can contain only AxSection components.

AxSection

AxSection is a generic control container. Any control can be a child of AxSection. All AxSection controls are rendered vertically, one after the other. Each AxSection includes a header that contains the title of the section and an image button that allows the user to expand or collapse the section. AxSection provides properties to display or hide the header and border. You can also set a security key on AxSection so that it’s visible only to users who have access to that security key in Dynamics AX. You can also write code when the section is expanded or collapsed through the events exposed by AxSection.

AxGroup

The AxGroup control contains the bound fields collection that displays the record information. You add AxGroup controls as descendents of AxSection controls. Typically, the immediate child of an AxSection control is a table control or an HTML table with AxGroup controls within the table cells. Figure 7-7 shows a sample task page in Enterprise Portal.

An Enterprise Portal task page with section and group controls

Figure 7-7. An Enterprise Portal task page with section and group controls

Following are some high-level control hierarchies for different form layouts.

Here is a form with a list of fields that are displayed one below the other.

<AxForm>
    <AxGroup><Fields>BoundFields or TemplateFields...</Fields> </AxGroup>
</AxForm>

This form has two expandable sections, with fields displayed one below the other.

<AxForm>
    <AxMultiSection>
        <AxSection>
              <AXGroup><Fields>BoundFields or TemplateFields...</Fields> </AxGroup>
        </AxSection>
        <AxSection>
              <AxGroup><Fields>BoundFields or TemplateFields...</Fields> </AxGroup>
              <AxGroup><Fields>BoundFields or TemplateFields...</Fields> </AxGroup>
        </AxSection>
    </AxMultiSection>
</AxForm>

The following form has two expandable sections, with fields displayed one below the other. In the second section, the groups are displayed in two columns.

<AxForm >
    <AXMultiSection>
        <AxSection>
            <AXGroup><Fields>BoundFields or TemplateFields...</Fields> </AXGroup>
        </AXSection>    <AxSection>
            <table>
                <tr><td>
                    <AXGroup><Fields>BoundFields or TemplateFields...</Fields> </AXGroup>
                </td><td>
                    <AXGroup><Fields>BoundFields or TemplateFields...</Fields> </AXGroup>
                </td></tr>
            </table>
        </AXSection>
    </AxMultiSection>
</AxForm>

Here is a wizard with two steps.

<AxForm>
    <asp:Wizard>
        <asp:WizardSteps>
            <asp:WizardStep>
                <AXGroup><Fields>BoundFields or TemplateFields...</Fields> </AXGroup>
            </asp:WizardStep>
           <asp:WizardStep>
                <AXGroup><Fields>BoundFields or TemplateFields...</Fields> </AXGroup>
            </asp:WizardStep>
        </asp:WizardSteps>
    </asp:Wizard>
</AxForm>

AxLookup

AxLookup is used in data entry pages to help the user pick a valid value for a field that references keys from other tables. In Enterprise Portal, lookups are metadata driven by default and are automatically enabled for fields based on the relationship defined in metadata in the AOT. An example is the customer group lookup on the customer creation page. The extended data type (EDT) and table relationship metadata in the AOT define a relationship between the customer table and the customer group table, so a lookup is rendered to pick a customer group on the customer group field when creating a customer record. You don’t need to write any code to enable this behavior—it happens automatically.

In some application scenarios, however, the automatic behavior isn’t sufficient, and you might be required to customize the lookup. The lookup infrastructure of Enterprise Portal is designed to offer flexibility and customization options in both X++ and in C# for developers to tailor the lookup user interface and the data retrieval logic to their needs.

In the AOT Data Set node, you can override the dataSetLookup method of the field in the data source to control the lookup behavior. For example, if you want to filter the values displayed for a zip code field based on what has been entered for a country, state, or county, you override dataSetLookup, as shown in the following code.

void dataSetLookup(SysDataSetLookup sysDataSetLookup)
{
    ;
    if (custTable.CountryRegionId)
sysDataSetLookup.parmQuery().dataSourceNo(1).addRange(
fieldnum(AddressZipCode,CountryRegionId)).value(queryValue(
custTable.CountryRegionId));
    if (custTable.State)
sysDataSetLookup.parmQuery().dataSourceNo(1).addRange(
fieldnum(AddressZipCode,State)).value(queryValue(custTable.State));
    if (custTable.County)
sysDataSetLookup.parmQuery().dataSourceNo(1).addRange(
fieldnum(AddressZipCode,County)).value(queryValue(custTable.County));
}

In the preceding example, addRange is used to restrict the value. For some scenarios, you might want to build the entire list dynamically. In that case, you can override the dataSetLookup method and build the entire query yourself.

...
...

Query               query;
List                _list;
_list = new List(Types::String);
query = new Query();
query.addDataSource(tablenum(ReturnReasonCode));
_list.addEnd(fieldstr(ReturnReasonCode,ReasonCodeId));
_list.addEnd(fieldstr(ReturnReasonCode,ReasonCodeGroupId));
_list.addEnd(fieldstr(ReturnReasonCode,Description));
sysDataSetLookup.parmLookupFields(_list);
sysDataSetLookup.parmQuery(query);
...
...

SysDataSetLookup in X++ provides many properties and methods to control the behavior of the lookup.

You can also customize the lookup in C# in the Web User Control by writing code in the Lookup event of bound fields or by using the AxLookup control for fields that don’t have data binding. To use AxLookup to provide lookup values for any ASP.NET control that isn’t data bound, you should set the TargetControlID property of the AxLookup to the ASP.NET control. You can base AxLookup on the EDT, the data set, the custom data set, or the custom User Control by specifying the LookupType property. You can also control what fields are displayed in the lookup and which one is a select field, either through the markup or through code. You can write code to override the Lookup event and control the lookup behavior, as shown in the following code.

protected void AxLookup1_Lookup(object sender, AxLookupEventArgs e)
    {
        AxLookup lookup = (AxLookup)sender;
        // Specify the lookup fields
        lookup.Fields.Add(AxBoundFieldFactory.Create(this.AxSession, lookup.
LookupDataSetViewMetadata.ViewFields["CustGroup"]));
        lookup.Fields.Add(AxBoundFieldFactory.Create(this.AxSession, lookup.
LookupDataSetViewMetadata.ViewFields["Name"]));
}

AxToolbar

The AxToolbar control provides an intuitive and consistent way to organize and display functions that the user performs frequently on your application’s Web pages. Typically, toolbars are displayed at the top of the page or grid control. AxToolbar extends the Windows SharePoint Services toolbar controls. AxToolbarMenu, used within AxToolbar, is derived from Microsoft.SharePoint.WebControls.Menu. The AxToolbar control is used to render a toolbar button with a drop-down menu that is rendered when the menu is clicked via a callback. In other words, AxToolbarMenu lets you modify the menu item properties before the menu items are rendered.

AxToolbarButton, used within the AxToolbar control, is derived from SPLinkButton. It is used to render top-level buttons.

Depending on your application, you can use either the AxToolbar ASP.NET control or the Dynamics Toolbar Web part to display the toolbar menu items on top of the list, overview, or task page. Generally, you use the Dynamics Toolbar Web part to control the display of toolbar menu items. But if you have a task page that contains master/detail information, such as a Purchase Requisition header and line items, you should use the AxToolbar ASP.NET control inside your Web User Control above the detail AxGridview control to allow the user to add and manage the line items.

You can use AxToolbar bound to AxDataSource or as an unbound control. When the controls are bound, the menu item context is automatically based on the current item selected on the grid view. When the controls are unbound, you have to write code to manage the toolbar context.

You can point the toolbar to Web Menus in the AOT through the WebMenuName property. The AOT Web Menus allow you to define multilevel menu structure with the SubMenu, MenuItem, and MenuItem reference nodes. Each top-level submenu in a Web menu is rendered by the AxToolbar control using AxToolbarMenu as a drop-down menu. Each top-level menu item is rendered using AxToolbarButton as a link button. If you have a submenu within a submenu, the second and further levels are displayed as flyout menus.

SetMenuItemProperties, ActionMenuItemClicking, and ActionMenuItemClicked are AxToolbar control-specific events. You use SetMenuItemProperties to change the behavior of drop-down menus, such as showing or hiding menu items based on the currently selected record, setting or removing context, and so on. An example of changing the menu item context in the SetMenuItemProperties event is shown in the following code.

void Webpart_SetMenuItemProperties(object sender, SetMenuItemPropertiesEventArgs e)
    {
        // Do not pass the currently selected customer record context, since this menu
is for creating new (query string should be empty)
     if (e.MenuItem.MenuItemAOTName == "EPCustTableCreate")
              ((AxUrlMenuItem)e.MenuItem).MenuItemContext = null;
    }

If you have user interface logic defined in a Web User Control and want to call this function instead of the one defined in the AOT when a toolbar item is clicked, you use ActionMenuItemClicking and ActionMenuItemClicked. For example, you can prevent the menu item from executing the action defined in the AOT by using the ActionMenuItemClicking event and defining your own action in C# using the ActionMenuItemClicked event in the Web User Control, as shown here.

void webpart_ActionMenuItemClicking(object sender, ActionMenuItemClickingEventArgs e)
    {
        if (e.MenuItem.MenuItemAOTName.ToLower() == "EPCustTableDelete")
        {
            e.RunMenuItem = false;
        }
    }
    void webpart_ActionMenuItemClicked(object sender, ActionMenuItemEventArgs e)
    {
   if (e.MenuItem.MenuItemAOTName.ToLower() == "EPCustTableDelete")
        {
                int selectedIndex = this.AxGridView1.SelectedIndex;
                if (selectedIndex != -1)
                {
                    this.AxGridView1.DeleteRow(selectedIndex);
                }
        }
    }

AxPopup

AxPopup controls are used to open a page in a pop-up browser window, to close a popup page, and to pass data from the pop-up page back to the parent page and trigger an OnPopupClosed server event on the parent. This functionality is encapsulated in two controls: AxPopupParentControl to use on the parent page and AxPopupChildControl to use on the pop-up page. Both controls derive from AxPopupBaseControl. These controls are AJAX compatible, so you can create them conditionally as part of a partial update. AxPopupParentControl allows a page, typically a Web part page, to open in a pop-up window. You can open a pop-up window from a client-side script by using the GetOpenPopupEventReference method. The returned string is a JavaScript statement that can be assigned, for example, to a button’s onclick attribute or to a toolbar menu item. The following code shows how a developer can open a pop-up window using client-side scripting by modifying the OnClick event.

  protected void SetPopupWindowToMenuItem(SetMenuItemPropertiesEventArgs e)
  {
      AxUrlMenuItem menuItem = new AxUrlMenuItem("EPCustTableCreate");
     //Calling the JavaScript function to set the properties of opening Web page on
clicking the menuitems.
        e.MenuItem.ClientOnClickScript = this.AxPopupParentControl1.GetOpenPopupEventR
eference(menuItem);
    }

You can also open a pop-up window from a server method by calling the OpenPopup method. Because pop-up blockers can block server-initiated pop-up windows, use OpenPopup only when absolutely necessary, for example, when only the server code can decide whether a pop-up window needs to be opened.

When placed on a pop-up page, AxPopupChildControl allows the page to close. You can close the pop-up page from a client-side script by using the GetClosePopupEventReference method, as shown in the following example.

this.BtnOk.Attributes.Add("onclick",
this.popupChild.GetClosePopupEventReference(true, true) + "; return false;");

You can close a pop-up window from the server event by using the ClosePopup method. Use the server method when additional processing is needed upon closing, such as performing an action or calculating values to be passed back to the parent page. There are two parameters to the ClosePopup and OpenPopup methods:

  • The boolean setFieldValues parameter indicates whether data needs to be passed back to the parent page.

  • The boolean updateParent parameter indicates whether the parent page needs to post back after the pop-up page is closed. If the value is true, AxPopupChildControl makes a call (via a client-side script) to the parent page to post back, with the AxPopupParentControl being the target. AxPopupParentControl then fires the PopupClosed server event, on which the parent page application code can get the values passed from the pop-up page and perform an action or simply update its state.

Data can be passed from the pop-up page back to the parent page using AxPopupField objects. You expose these objects via the Fields property of the AxPopupBaseControl, from which both AxPopupParentControl and AxPopupChildControl are derived.

AxPopupParentControl and AxPopupChildControl have fields with the same names. When the pop-up page closes, the value of each field of AxPopupChildControl is assigned (via a client-side script) to the corresponding field in AxPopupParentControl.

AxPopupField can optionally be associated with another control, such as TextBox or any other control, by assigning its TargetId property to the ID property of the target control. This is useful, for example, when the pop-up page has a TextBox control. To pass the user input to the parent page upon closing the pop-up page—and to do it entirely on the client to avoid a round-trip—you need to associate a field with the TextBox control. When AxPopupField isn’t explicitly associated with a target control, it gets implicitly associated with a HiddenField control automatically created by AxPopupParentControl or AxPopupChildControl.

You can then set the value of the field on the server via the SetFieldValue method. Typically, you call SetFieldValue on AxPopupChildControl, and you can call it at any point of user interaction with the pop-up page, including the initial rendering or the closing of the page. The value of the field can be retrieved via the GetFieldValue method. Typically, it is called on AxPopupParentControl during the processing of the PopupClosed event. You can clear the values of nonassociated fields by calling the ClearFieldValues method.

You can also set or retrieve values of AxPopupFields on the client by manipulating the target control value. You can retrieve target control, whether explicitly or implicitly associated, by using the TargetControl property.

BoundField Controls

BoundField controls are used by data-bound controls (such as AxGridView, AxGroup, ASP.NET GridView, and DetailsView) to display the value of a field through data binding. They are displayed differently depending on the data-bound control in which they are used. For example, the AxGridView control displays a BoundField object as a column, whereas the AxGroup control displays it as a row.

The Enterprise Portal framework provides a number of enhanced AxBoundField controls that are derived from ASP.NET-bound field controls but integrated with the Dynamics AX metadata.

Table 7-1 describes the AxBoundField controls.

Table 7-1. AxBoundField Controls

Type

Purpose

AxBoundField

You use AxBoundField to display text values. The DataSet, DataSetView, and DataField properties define the source of the data.

AxHyperLinkBoundField

You use AxHyperLinkBoundField to display hyperlinks. You use the MenuItem property to point to a Web menu item in the AOT for generating the URL and the DataSet, DataSetView, and DataField properties to define the source of the data. If the Web menu name is stored within the record, you use DataMenuItemField instead of MenuItem.

AxBoundFieldGroup

You use AxBoundFieldGroup to display FieldGroups defined in the AOT. The DataSet, DataSetView, and FieldGroup properties define the source of the data.

Other BoundFields

You use AxCheckBoxBoundField to display a boolean field in a check box, AxDropDownBoundField to display a list of values in a drop-down menu, and AxRadioButtonBoundField to display a list of values as radio buttons. For all these properties, you use DataSet, DataSetView, and DataField to define the source of the data. For a radio button, you use RepeatDirection to define whether the radio button should be rendered horizontally or vertically.

Depending on the field type, BoundFieldDesigner automatically groups fields under the correct BoundField type. The BoundField type displays text that allows you to control the lookup behavior through the LookupButtonDisplaySettings property and the lookup event.

Web Parts

Web parts are pluggable and reusable Windows SharePoint Services components that generate HTML and provide the foundation for the modular presentation of data. Web parts are easily integrated to assemble a Web page and support customization and personalization. Enterprise Portal comes with a standard set of Web parts, including the following, that expose the business data from Dynamics AX:

  • Dynamics User Control. Used for hosting any ASP.NET control. The Dynamics User Control Web part points to a Managed Web Content Item that secures the Web control. The Dynamics User Control Web part can serve as a provider, a consumer, or both when connected with other Web parts. The Web part role property defines the role and is used to pass or record context and refresh the control using AJAX without the entire page being refreshed.

  • Dynamics Infolog Web Part. Used for displaying Dynamics AX Infolog messages on the Web page. When you create a new Web part page, Enterprise Portal page templates automatically add the Infolog Web Part to the new Web part’s header zone. Any error, warning, or information message Dynamics AX generates is automatically displayed by the Dynamics Infolog Web Part. If you need to display some information from your Web User Control in the Dynamics Infolog Web Part, you need to add the message to the C# proxy class for the X++ Infolog object.

  • Dynamics Page Title. Used for displaying the page title and the browser title. When you create a new Web part page, the Dynamics Page Title Web part is automatically added to the title bar zone. By default, the Dynamics Page Title Web part displays the title information specified in the PageTitle property of the Page Definition node in the AOT. If no page definition exists, the page name is displayed. You can override this default behavior and make this Web part get the title from any other Web part in the Web page by using a Web part connection. For example, if you’re developing a list page and you want to display some record information, such as Customer Account and Name as the page title, you can connect the Dynamics User Control Web part that displays the grid to the Dynamics Page Title Web part. When you select a different record in the customer list, the page title and the browser title change to display the currently selected Customer Account and Name.

  • Dynamics QuickLaunch. Used for displaying navigation links on the left side of pages in Enterprise Portal. When you create a new Web part page, the Dynamics QuickLaunch Web part is automatically added to the Left Column zone if the template that you chose has this zone. The Dynamics QuickLaunch Web part displays the Web menu set in the QuickLaunch property of the Web module in the AOT for that page. All the pages in a given Web module (subsite) display the same left navigation.

  • Dynamics Left Navigation. Used to display page-specific navigation instead of module-specific navigation if necessary. You would then use the Dynamics Left Navigation Web part instead of the Dynamics QuickLaunch Web part.

  • Dynamics Toolbar. Used to display the toolbar at the page level. The Web menu property points to the WebMenu node in the AOT. The toolbar is generally connected to the Dynamics User Control Web part, which displays a grid or form for taking action. You can write code in the Web User Control displayed by the Dynamics User Control Web part to control the toolbar behavior rendered by the Dynamics Toolbar Web part.

  • Dynamics unified Worklist. Used to display workflow action, alert notification, and tasks, generally in the Role Center or on the Home page.

  • Dynamics Report Server Report. Used to display SQL Server Reporting Services for Dynamics AX.

  • Cues. Used to display information as a visual paper stack in Role Centers. See Chapter 8, for in-depth coverage of cues.

  • Quick Links. Used to display shortcuts to frequently used menu items in Role Centers. Chapter 8 discusses Quick Links in depth.

  • Business Overview. Used to display KPIs and historical comparisons in Role Centers. Refer to Chapter 8 for details.

Figure 7-8 shows the Add Web Parts dialog box in Enterprise Portal.

Add Web Parts dialog box in Enterprise Portal

Figure 7-8. Add Web Parts dialog box in Enterprise Portal

Programming Enterprise Portal Controls

This section covers some of the common programming tasks involved in building and modifying Enterprise Portal controls and explains the technology behind them with code samples.

AJAX

ASP.NET AJAX allows the developer to create ASP.NET Web pages that can update data on the Web page without completely reloading the page. ASP.NET AJAX provides client-side and server-side components that use the XMLHttpRequest object along with JavaScript and DHTML to enable portions of the page to update asynchronously, again without reloading the entire page. With ASP.NET AJAX, you can develop Enterprise Portal Web pages, just as you would any regular ASP.NET page, and you can declaratively mark the components that need to be rendered asynchronously.

Using the UpdatePanel server control, you can enable sections of the Web page to be partially rerendered without an entire page postback. The Dynamics User Control Web part contains the UpdatePanel internally, and ScriptLibrary is included in the master page, so any control that you use in the Web User Control instantly leverages AJAX without you needing to write any explicit markup or code.

For example, if you add a text box and button, writing code for the button’s click event on the server, without AJAX, when you click the button, the entire page refreshes. But when you load the same control through the Dynamics User Control Web part, it leverages AJAX and updates the text box without refreshing the entire page.

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><asp:Button ID="Button1"
runat="server" onclick="Button1_Click" Text="Button" />

And in the code-behind, update the text box with the current time after 5 seconds.

protected void Button1_Click(object sender, EventArgs e)
    {
     System.Threading.Thread.Sleep(5000);
     TextBox1.Text = System.DateTime.Now.ToShortTimeString();
    }

If you want to override the AJAX behavior and force a full postback, you can use the PostBackTrigger control in your Web User Control, as shown here.

<%@ Register assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicK
eyToken=31bf3856ad364e35" Namespace="System.Web.UI" TagPrefix="asp" %>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
    </ContentTemplate>
    <Triggers>
        <asp:PostBackTrigger ControlID="Button1" />
    </Triggers>
</asp:UpdatePanel>

Session

All the Web parts in a Web page share the same session in Dynamics AX. Once the page is served, the session is torn down. To optimize performance, you can control the time frame for tearing down the session through a web.config setting. For example, add the Microsoft.Dynamics sectionGroup to web.config as in the following code.

<sectionGroup name="Microsoft.Dynamics">
<section name="Session" type="System.Configuration.SingleTagSectionHandler, System,
Version=1.0.5000.0, Culture=neutral,PublicKeyToken=b77a5c561934e089" />
</sectionGroup>

Add the <Microsoft.Dynamics> element under </system.web> and then add the following text to the file.

<Microsoft.Dynamics>
     <Session Timeout="15" />
</Microsoft.Dynamics>

Many of the methods you use in the Enterprise Portal framework to add code to User Controls require access to the Session object. You need to pass the Session object when using proxy classes. You can access the Session object through the Web part hosting the User Control, as shown here.

AxBaseWebPart webpart = AxBaseWebPart.GetWebpart(this);
return webpart == null ? null : webpart.Session;

Context

Context is a data structure used to share data related to the current environment and user actions taking place with different parts of a Web application. Context lets you know what’s happening in one control so you can react to it via another control or Web part, or pass that information to a new page. Generally, information about the current record the user is working on forms the context. For example, when the user selects a row in a grid view, other controls might need to get information about the newly selected row to react.

AxContext is an abstract class that encapsulates the concept of the context. AxTableContext and AxViewContext derive from and implement AxContext. AxTableContext is for table-based context, and AxViewContext is for data set view context. A view can contain more than one table, so it contains an AxTableContext object for each table in the view in the TableContextList collection. The RootTableContext property returns the TableContext of the root table in that data set view. AxViewDataKey uniquely identifies the AxViewContext, and it contains the TableDataKeys collection. AxTableDataKey uniquely identifies AxTableContext. An event is raised whenever the context changes. If the context is changed within the Web User Control, the CurrentContextChanged event is raised. If the context changes from other Web parts that are connected to it, the ExternalContextChanged event is raised.

You can write code in these events on the AxBaseWebPart from your Web User Control and use the CurrentContextProviderView or ExternalContextProviderView and ExternalRecord properties to get the record associated with the context. You can fire all these events programmatically from your application logic by calling FireCurrentContextChanged or FireExternalContextChanged so that all other connected controls could react to the change you made through your code.

Following is sample code to fire the CurrentContextChanged event.

void CurrentContextProviderView_ListChanged(object sender, System.ComponentModel.
ListChangedEventArgs e)
    {
/* The current row (which is the current context) has changed -
 update the consumer webparts.Fire the current context change event to refresh
 (re-execute the query) the consumer webparts
*/
AxBaseWebPart webpart = this.WebPart;
webpart.FireCurrentContextChanged();
   }

Sample code for getting the record from the connected Web part follows. First subscribe to the ExternalContextChanged event in the consumer Web User Control, as here.

protected void Page_Load(object sender, EventArgs e)
    {
   //Add Event handler for the ExternalContextChange event. Whenever selecting
//the grid of the provider Web part changes, this event gets fired.

        (AxBaseWebPart.GetWebpart(this)).ExternalContextChanged += new
EventHandler<Microsoft.Dynamics.Framework.Portal.UI.AxExternalContextChangedEventArgs>
(AxContextConsumer_ExternalContextChanged);
}

Then get the record passed through the external context, as shown here.

    void AxContextConsumer_ExternalContextChanged(object sender, Microsoft.Dynamics.
Framework.Portal.UI.AxExternalContextChangedEventArgs e)
    {
        //Get the AxTableContext from the ExternalContext passed through web part
connection and construct the record object
        //and get to the value of the fields
        IAxaptaRecordAdapter currentRecord = (AxBaseWebPart.GetWebpart(this)).
ExternalRecord;
        {
   if (currentRecord != null)
            {
   lblCustomer.Text = (string)currentRecord.GetField("Name");
            }
        }
    }

Data

The Enterprise Portal ASP.NET controls access and manipulate data through data binding to AxDataSource. You can also access the data through the APIs directly. The Microsoft.Dynamics.Framework.Data.Ax namespace contains several classes that work together to retrieve data.

For example, use the following code to get the current row from the DataSetView.

private DataSetViewRow CurrentRow
    {
        get
        {
            try
            {
                DataSetView dsv = this.ContactInfoDS.GetDataSet().DataSetViews[this.
ContactInfoGrid.DataMember];
                return (dsv == null) ? null : dsv.GetCurrent();
            }
            // CurrentRow on the dataset throws exception in empty data scenarios
            catch (System.Exception)
            {
                return null;
            }
        }
    }

To set the menu item with the current records context, use the following code.

...
...
DataSetViewRow currentContact = this.dsEPVendTableInfo.GetDataSourceView(gridConatcts.
DataMember).DataSetView.
GetCurrent();
     using (IAxaptaRecordAdapter contactPersonRecord = currentContact.GetRecord())
                {
   ((AxUrlMenuItem)e.MenuItem).MenuItemContext = AxTableContext.Create(AxTableDataKey.
Create(this.BaseWebpart.Session, contactPersonRecord, null));
                }

Metadata

The Enterprise Portal framework provides a rich set of APIs to access the metadata from the AOT in managed code. The Microsoft.Dynamics.Framework.Metadata.Ax namespace contains several classes that work together to retrieve metadata from the AOT. Enterprise Portal controls use the metadata for retrieving formatting, validation, security, and other information from the AOT and apply it on the Web user interface automatically. Developers can also use these APIs to retrieve the metadata in their user interface logic.

MetadataCache is the main entry point to accessing metadata and provides static methods. For example, to get the EnumMetadata, you use MetadataCache.GetEnumMetadata, as shown here.

/// <summary>
/// Loads the dropdown with the Enum values.
/// </summary>
private void LoadDropdownList()
    {
   EnumMetadata salesUpdateEnum = MetadataCache.GetEnumMetadata(this.AxSession,
EnumMetadata.EnumNum(this.AxSession, "SalesUpdate"));
        foreach (EnumEntryMetadata entry in salesUpdateEnum.EnumEntries)
        {
   ddlSelectionUpdate.Items.Add(new ListItem(entry.GetLabel(this.AxSession), entry.
Value.ToString()));
        }
    }

To get the label value for a table field, use the following code.

...
...
TableMetadata tableSalesQuotationBasketLine = MetadataCache.GetTableMetadata(
                            this.AxSession, "CustTable");
TableFieldMetadata fieldItemMetadata = tableSalesQuotationBasketLine.FindDataField-
("AccountNum");
String s = fieldItemMetadata.GetLabel(this.AxSession);
...
...

Figure 7-9 shows some key object access hierarchy for metadata. Not all APIs are included in this figure.

Metadata object hierarchy

Figure 7-9. Metadata object hierarchy

Labels

Dynamics AX uses a localizable text resource file, the label file, to provide messages to the user and for user interface text, Help text in the status bar, captions, and so on. You can use labels to specify the user interface text in Web User Controls and for the AOT Web node element properties. You can add labels by setting the Label property in the AOT or by using X++ code.

When you use data-bound controls such as AxGridView or AxForm for the user interface, the bound fields automatically pick the label associated with the field in the AOT and render it in the user’s language at run time.

If you want to show a label in your Web User Control for non-data-bound scenarios, use the AxLabel expression.

AxLabel is a standard ASP.NET expression that looks up the labels defined in the AOT and renders them in the user’s language when the page is rendered. To add the AxLabel expression, you can use the expression editor available in the design view of the User Control by clicking the button that appears on the (Expressions) property. Alternatively, you can type the expression directly in the markup, like this.

<asp:Button runat="server" ID="ButtonChange" Text="<%$ AxLabel:@SYS70959 %>"
OnClick="ButtonChange_Click" />

You can also add labels through code using the Labels class, as shown here.

string s = Microsoft.Dynamics.Framework.Portal.UI.Labels.GetLabel("@SYS111587");

Enterprise Portal caches the labels for all 41 languages for better performance. So if you add or change a label in the AOT, you need to clear the cache on the Enterprise Portal site by using the Refresh AOD admin option.

Formatting

Dynamics AX is a truly global product, supporting multiple languages and used in many countries. Displaying data in the correct format for each localized version is a critical requirement for any global product. Through metadata, the Enterprise Portal framework recognizes the user’s current locale and system settings and automatically displays data in the correct format in the data-bound controls.

If you’re not using data-bound controls and want your unbound ASP.NET controls to be formatted just like Enterprise Portal controls, you can leverage the AxValueFormatter class in the Enterprise Portal framework. This class implements ICustomFormatter and the IFormatProvider interface and defines a method that supports custom, user-defined formatting of an object’s value and provides a mechanism for retrieving an object to control formatting. For the various data types, specific ValueFormatter classes derived from AxValueFormatter are implemented: AxStringValueFormatter, AxDateValueFormatter, AxDateTimeValueFormatter, AxTimeValueFormatter, AxRealValueFormatter, AxNumberValueFormatter, AxGuidValueFormatter, and AxEnumValueFormatter.

You use AxValueFormatterFactory to create AxValueFormatter objects. You can create any of the preceding formatters, or you can create a formatter based on an EDT in Dynamics AX. The data type for the extended data is retrieved from the metadata object for the EDT, and the culture information comes from the context. The various rules for languages and countries, such as number formats, currency symbols, and sort orders, are aggregated into a number of standard cultures. The Enterprise Portal framework identifies the culture based on the user’s language setting in Dynamics AX and makes this information available in the context. Formatter objects have a Parse method you can use to convert a string value back into the underlying data type. For example, the following code formats the data based on a given EDT.

private string ToEDTFormattedString(object data, string edtDataType)
    {
   ExtendedDataTypeMetadata edtType = MetadataCache.GetExtendedDataTypeMetadata(
            this.AxSession,
            ExtendedDataTypeMetadata.TypeNum(this.AxSession, edtDataType)
        );
        IAxContext context = AxContextHelper.FindIAxContext(this);
        AxValueFormatter valueFormatter = AxValueFormatterFactory.
CreateFormatter(this.AxSession, edtType, context.CultureInfo);
        return valueFormatter.FormatValue(data);
    }Validation

You use ASP.NET validator controls to validate user input on the server as well as (optionally) on the client (browser). The Enterprise Portal framework has ASP.NET validators specific to Dynamics AX: AxBaseValidator derives from BaseValidator, and AxValueFormatValidator derives from AxBaseValidator. Both are metadata driven and are used intrinsically by bound fields, but you can also use them in unbound scenarios.

ASP.NET validators are automatically validated when a postback that causes validation occurs. For example, an ASP.NET Button control causes validation on the client and the server when clicked. All validators registered on the page are validated. If any validator is found to be invalid, the page becomes invalid, and Page.IsValid returns false.

The importance of Page.IsValid is best highlighted with an example. Let’s say you add an ASP.NET button in which some business logic is performed in OnClick before it is redirected. As mentioned, the button causes validation by default, so validators are executed before the OnClick event is fired. If you don’t check whether the page is valid in your OnClick, you will be redirected even though a validation error that requires the user’s attention occurs.

Enterprise Portal controls such as AxForm and AxGridView won’t perform the requested action if validation fails and navigates away from the page. The Dynamics AX validator controls automatically write any validation errors to the Infolog.

Best Practices

Best Practices

When you’re using ASP.NET controls directly rather than using Enterprise Portal controls, as a best practice, make sure the Pages.IsValid flag is checked before any actions, such as navigating away from the current page, are completed. You want to do this because, in case any errors occur, you want to keep the current page with Infolog displaying the errors for the users so that they will notice them and take corrective action.

Error Handling

In Enterprise Portal, .NET Business Connector (including proxies), the metadata, and the data layer all throw exceptions in case of error conditions. The Enterprise Portal ASP.NET controls automatically handle these exceptions, taking appropriate actions and displaying the errors in Infolog.

Exceptions in Enterprise Portal are divided into three categories. These exception categories are defined in the enumeration AxExceptionCategory:

  • NonFatal. The exception handling code should respond appropriately and allow the request to continue normally.

  • AxFatal. Indicates that an unrecoverable error has occurred in Enterprise Portal. Enterprise Portal content will not display. Content not related to Enterprise Portal should display as expected.

  • SystemFatal. Indicates that a serious error, such as out of memory, has occurred and the request must be aborted. Errors of this kind often cause an HTTP error code 500.

If your code directly calls methods in data or metadata layers from Enterprise Portal or with proxy class calling X++ methods, it must handle these exceptions. The following code shows how to use AxControlExceptionHandler in the try-catch statement to handle exceptions.

Try
{
    // Code that may encounter exceptions goes here.
}
catch (System.Exception ex)
{   AxExceptionCategory exceptionCategory;
    // Determine whether the exception can be handled.
    if (AxControlExceptionHandler.TryHandleException(this, ex, out exceptionCategory)
== false)
    {
        // The exception was fatal and cannot be handled. Rethrow it.
        throw;
    }
    if (exceptionCategory == AxExceptionCategory.NonFatal)
    {
   // Application code to properly respond to the exception goes here.
    }
}

AxControlExceptionHandler tries to handle Dynamics AX exceptions based on the three exception categories just mentioned. It returns true if the exception is NonFatal.

ViewState

The Web is stateless, which means that each request for a page is treated as a new request, and no information is shared. When loaded, each ASP.NET page goes through a regular page life cycle, from initialization and page load onward. When a user interacts with the page, causing the need for the server to process some control events, ASP.NET posts the values of the form to the same page for processing the event on the server. A new instance of the Web page class is created each time the page is requested from the server. When postback happens, ASP.NET uses the ViewState feature to preserve the state of the page and controls so that any changes made to the page during the round-trip are not lost. The Enterprise Portal framework leverages this feature, and Enterprise Portal ASP.NET controls automatically save their state to ViewState. The ASP.NET page reads the view state and reinstates the page and control state in its regular page life cycle. So you don’t need to write any code to manage the state if you’re using Enterprise Portal controls. But if you want to persist any values in memory variables, you can write code to add or remove items from StateBag in ASP.NET. If you need to save the state of an X++ data set, you can use the pack and unpack design pattern to store the state, as shown here.

public int Counter
{
    get
     {
        Object counterObject = ViewState["Counter"];
        if (counterObject == null)
        {
            return 0;
        }
       return (int)counterObject;
     }
    set
     {
        ViewState["Counter"] = value;
    }
}

The Enterprise Portal framework uses the EPStateStore table in Dynamics AX to store the state of AxDataSourceControl. The states of all other controls are stored in the ASP.NET view state for added security. This storage is per user, and each user can read only his or her information. Writes and deletes are protected with AOS methods, and read is protected via code access permission.

Page Life Cycle

When an Enterprise Portal page runs, it goes through a life cycle in which it performs a series of steps and raises events at various states so developers can write code to control the behavior of the page and its controls, create dynamic controls, and write user interface logic. Understanding the sequence of the page processing and events helps you write the user interface logic at the appropriate level.

Proxy Classes

If you need to call X++ classes or table methods or enums in your Web User Control, the Enterprise Portal framework provides an easy way of creating managed wrappers for these X++ objects and using them in your Web User Control. A proxy file internally wraps the .NET Business Connector calls and provides a simple, easy-to-use, typed interface for C# applications. The proxies file under WebWeb FilesStatic Files in the AOT contains information about all the X++ objects for which a proxy file needs to be generated. The proxy generation tool uses this file when the Enterprise Portal site is deployed. The proxy files are automatically created and deployed to the App_Code folder of the IIS Web site. Table 7-2 describes the various command line options for the proxy generator.

Table 7-2. Proxy Generator Command Line Options

Option

Purpose

/ class

Specifies the name of a class to generate. The /method option is used to further specify the composition of the generated class type.

/enum

Specifies the name of a base enumeration to generate.

/generate

Specifies the generate mode: optional values are classes, enums, and tables. If the /generate option isn’t specified or if no option value is specified, the /class, /enum, and /table options determine what types are generated.

If the classes value is specified, all AOT classes are generated.

If the enums value is specified, all AOT base enumerations are generated.

If the tables value is specified, all AOT tables are generated.

/method

Specifies the name of a method to generate. The class (or table) and method name must be specified as follows: class.method.

/methods+

Specifies that all methods will be generated, ignoring the methods specified by the /method options.

/methods-

Default. Specifies that only the methods specified by the /method options will be generated.

/namespace

Specifies the namespace for the generated proxies.

/references+

Specifies that all class references will be generated. A reference is a generated type that appears as a base class, or as a method return type or parameter type.

/references-

Default. Specifies that no class references will be generated.

/table

Specifies the name of a table to generate. The /method option is used to further specify the composition of the generated class type.

/warn

Specifies the proxy generator warning level: 0 Off, 1 Error, 2 Warn, 3 Info, and 4 Verbose.

For example, to generate a proxy file for the SampleProxy class, add the following code to the WebWeb FilesStatic FilesProxies node in the AOT.

warn:2 /references+ /methods- /namespace:Microsoft.Dynamics.Portal.Application.Proxy

/class:SampleProxy
  /method:SampleProxy.sampleProxiesNoParameters
  /method:SampleProxy.sampleProxiesStaticMethod

The first line of the preceding code provides the generation options for the proxy file. The second line provides information about the X++ class for which the proxy file needs to be generated. When Enterprise Portal is deployed, a SampleProxy.cs is created; it contains two methods and is deployed to the App_Code folder of the IIS Web site.

From Visual Studio, you can right-click the App_Code folder in a Dynamics AX Web project and choose the Generate Proxies option. The Visual Studio add-in generates the proxy files defined in the Proxies file and adds them to the Visual Studio project.

To use the proxy from C# code in the Web User Controls, first add a using statement to the proxy namespace, like this.

using Microsoft.Dynamics.Portal.Application.Proxy;

Then you can access these X++ methods as if they were in C#. You can access some items in the proxy, such as enums, directly, without any additional code. Accessing methods from the proxy requires passing the IAxaptaAdapter object together with the method call. So you need to get the session and pass it to the constructor to create the C# proxy object, as shown here.

protected string NoParamProxyCall_Click(object sender, EventArgs e)
    {
        AxBaseWebPart webpart = AxBaseWebPart.GetWebpart(this);
        SampleProxy sampleProxy = null;
        sampleProxy = new SampleProxy(webpart.Session.AxaptaAdapter);
        string s = sampleProxy.sampleProxiesNoParameters();
        return s;
    }

Securing Web Elements

To securely expose Web User Controls through Web parts in Windows SharePoint Services, you must create a Web managed node pointing to the Web control in the AOT. You can assign security keys, along with other configuration keys, to the Web node. You can assign parameters (if the Web User Control uses them) to exhibit different behavior on different pages. Figure 7-10 shows the SecurityKey property of a Web node.

Assigning a security key to Web content

Figure 7-10. Assigning a security key to Web content

You can also secure both Web and non-Web applications in Dynamics AX at the data access level by using table-level, field-level, or record-level security settings. Using security keys is the primary way to set permission levels for groups in Dynamics AX. After you configure security keys to define the features the application should include, the keys are used to grant permissions to individual groups. These permissions regulate how group members are allowed to work with each object in a database. You can apply more granular control by creating your own groups, assigning appropriate permissions to those groups, and then adding users to the groups.

At logon, the security keys determine user access. Access depends on which user groups the user is in and on the user’s company or domain. Because the access to an individual security key depends on its parent, the system automatically traverses the security key hierarchy and presents the correct access level to the user. You can set up access to Web menu items and Web content in the User Group Permissions dialog box (accessible from Administration SetupSecurityUser Group Permissions). You can use the Viewing list to apply a different view to the tree structure.

If a user doesn’t have access to a Web menu item, that item doesn’t appear on the user’s Web menu. If the Web menu item is linked from other Web User Controls the user has access to, the item linked with the Web menu item appears as text rather than a link.

If the user doesn’t have access to Web content on a Web page, the content isn’t rendered on the page. The Web part properties also limit the items displayed in the drop-down list based on the user permissions for the underlying objects. Moreover, the types of operations that are allowed on these objects depend on the access level set for the objects on the groups to which the user belongs.

Developing the Navigation

Web modules are resources in the AOT that define the sites and subsites in Windows SharePoint Services that make up an Enterprise Portal installation. Web module resources also define the top-level navigation structure for Enterprise Portal.

Web menu items define the basic navigational element. They can point to either a URL or a class. Web menu items can be secured by security keys. You can use menu items in Web menus as navigational elements on a Web page, or you can use controls (e.g., buttons) in Web User Controls to provide links. Whether the links are shown or hidden is based on user permissions. Consider Web menu items the glue and the navigation mechanism throughout the Web site to help you create sites that are dynamic and versatile.

A Web menu defines the hierarchical navigational scheme and comprises Web menu items, submenu headings, and references to other Web menus. Web menus can be included on the Web page through the Dynamics Quick Launch, Dynamics Left Navigation, or Dynamics Toolbar Web part.

The Web framework uses the WebLink class to generate hyperlinks. This class has all the properties and methods the framework needs to pass information back and forth between the browser and the server. More important, it has a method that returns the URL for the link. WebLink also has several methods for passing record information.

Figure 7-11 shows the AOT nodes for Web menus, Web menu items, and Web modules.

Web Menus and Web menu items

Figure 7-11. Web Menus and Web menu items

Windows SharePoint Services displays a TopNavigation bar by using a SPNavigationProvider registered in web.config. This bar is used on the master page as a SiteMapDataSource for the QuickLaunch and TopNavigationMenus, respectively. Office SharePoint Server overrides the Windows SharePoint Services SPNavigationProvider and uses Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider to display TopNavigation and QuickLaunch.

The Enterprise Portal site uses the Windows SharePoint Services navigation elements and object model for showing Dynamics AX navigation items from the AOT. To display Web menus from the AOT as the top and left navigation elements on the Windows SharePoint Services site, Enterprise Portal setup adds the navigation providers DynamicsLeftNavProvider and DynamicsTopNavProvider, which are new in Dynamics AX 2009. For MOSS, DynamicsMOSSTopNavProvider is added instead of AxTopNavProvider. Both navigation providers override the default TopNavigationDataSource and QuickLaunchDataSource (for Windows SharePoint Services) and the default PortalSiteMapDataSource (for MOSS).

Web Files

You can customize Windows SharePoint Services sites by using site definitions or custom templates built on existing site definitions. The site definitions encompass multiple files located on the file system on each Web server. These files define the structure and schema for the site. You can create new site definitions by copying the existing site definition files and modifying them to meet the needs of the new sites. You create custom templates by using the user interface to customize existing sites and storing them as templates.

The Enterprise Portal site definition files are stored in the AOT under WebWeb FilesSite Definitions. Custom templates are stored under WebWeb FilesSite Templates. The Enterprise Portal setup deploys these files from the AOT to the Web server file system and Windows SharePoint Services or Office SharePoint Server.

Enterprise Portal includes one default site definition, which has two configurations: one for authenticated users and another for public Internet users. Even though Enterprise Portal doesn’t include any site templates, the AOT provides a mechanism for partners and customers to add custom templates and let the Enterprise Portal Deployment Wizard implement these files.

The site definition is deployed to the <drive>:Program FilesCommon FilesMicrosoft Shared Web Server Extensions12TEMPLATESiteTemplatesAXSITEDEF folder.

This folder contains the Enterprise Portal master page (defaultax.master) and the default.aspx and onet.xml files. The Web part page templates are deployed to the language-specific site definition folder: <drive>:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions12TEMPLATE<lcid>AXSITEDEF.

Enterprise Portal deployment is implemented as a set of four Windows SharePoint Services features. A Windows SharePoint Services site represents a modular server-side, file-systemlevel customization that contains items that can be installed and activated in a Windows SharePoint Services environment. The feature definitions are deployed to <drive>:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions12TEMPLATEFEATURES.

These Enterprise Portal feature definitions are as follows:

  • DynamicsSearch. Enables Enterprise Portal search control on Enterprise Portal sites that enable searching across Dynamics AX and Windows SharePoint Services data.

  • DynamicsAxEnterprisePortal. Enables basic Enterprise Portal deployment steps such as deploying master and other files and components, setting navigation providers, and registering Dynamics AX. This feature is for the Windows SharePoint Services environment.

  • DynamicsAxEnterprisePortalMOSS. Includes environment-specific steps for deploying Office SharePoint Server.

  • DynamicsAxDataConnection. For deploying the Office Data Connection fields used by KPI lists and the Business Overview Web part in Role Centers.

Enterprise Portal feature-related files are stored in the AOT under WebWeb FilesStatic Files. The Static Files node also has other infrastructure-related files, such as the aspx file used for importing and exporting page and list definitions, search control, document handling infrastructure files, the master page, common ASP.NET pages, images, style sheets, and configuration files.

EPSetupParams is an XML file used to define the default Enterprise Portal site attributes, such as title, description, and URL, when the site is autocreated through Enterprise Portal setup.

Proxies is a text file used during Enterprise Portal deployment to generate C# proxy files for the X++ class and table methods and enums.

The Enterprise Portal site definition contains the page templates embedded with the Web Menu Web part to display the global menu and the Dynamics Page Title Web part to display the page title using Dynamics AX labels. So when a page is created in Enterprise Portal, these two Web parts are already available on the Web page, creating consistency across all Web part pages in Enterprise Portal and supporting rapid application development. Figure 7-12 shows some of the key files that constitute the site definition and their locations on the Web server.

Enterprise Portal site definition on the Web server

Figure 7-12. Enterprise Portal site definition on the Web server

Enterprise Portal Web parts are packed into one Web part package and kept in the AOT under WebWeb FilesWeb Parts. If necessary, partners and customers can add their own Web part packages under this node, and Enterprise Portal will deploy these files to the global assembly cache on the Web server and add a safe control entry in the web.config file.

Web part pages display one or more Web parts. Web parts provide an easy way to build powerful Web pages that display a variety of information, ranging from a Dynamics AX data view of a list in the current site to external data presented in custom-built Web parts. You create Web part pages in Windows SharePoint Services by using Microsoft Internet Explorer. You simply drag Web parts onto Web part pages and set their properties with prepopulated lists. You can edit Web part pages in either SharePoint Designer or Internet Explorer. You can use Internet Explorer to edit a page and change its Web parts, arrange the order of the Web parts, and set the Web part properties. You can use SharePoint Designer to insert logos or other graphics, to customize document libraries or lists, to apply themes and styles, to customize the master page, and so on. Keep in mind, however, that you can’t import pages edited with SharePoint Designer into the AOT.

All the Web parts on a Web page share the same Dynamics AX Web session. You can import Web part pages created in the Enterprise Portal site in Windows SharePoint Services into the AOT as page definitions by using the Import Page tool from the Web menu items of type URL. The page definitions are stored in the AOT under WebWeb FilesPage Definitions.

The page definitions imported into the AOT automatically create pages when a site is created with the Enterprise Portal site definition. The PublicPage property of the page definition node determines whether the page should be created on the public site. All the pages are created for the authenticated site. The page definition Title property, if used, must be set to a label so that the page displays the localized title when used with different language settings.

Style sheets and other necessary files, such as lookup files and images for Enterprise Portal, are kept under WebWeb FilesStatic Files. Web parts refer to these style sheets. Each Web part applies the current theme and uses it to refer to the corresponding Enterprise Portal style sheets.

For example, if the folder name of the currently applied theme in the Enterprise Portal site is Afternoon, the Web part refers to the AXEP.css file from the Enterprise Portal Stylesheets folder. This folder is located on the Web server under <drive>:Program FilesCommon Files Microsoft SharedWeb Server Extensions12TEMPLATELAYOUTSepStylesheets.

For each theme, Enterprise Portal has four style sheets. AXEP.css is the base style sheet. EP.AXEP_RTL.css is used for right-to-left languages, cascading on top of AXEP.css. AXEP_ CRC.css and AXEP_CRC_RTL.css are used for Role Centers when rendered on AxClient.

If the Web part doesn’t find a corresponding file, the default Enterprise Portal style sheet is applied. Dynamics AX includes four style sheets for Enterprise Portal that map to the default theme in Windows SharePoint Services. Partners and customers can also extend the built-in style sheets or create new ones that map to any Windows SharePoint Services theme. Windows SharePoint Services also allows you to create new themes.

Import and Deploy Page/List Tools

The Import and the Deploy Page/List tools provide a seamless integration between the AOT and Enterprise Portal sites based on Windows SharePoint Services or Office SharePoint Server.

The Import Page tool allows you to pull pages you create in Windows SharePoint Services into the URL Web Menu node in the AOT. The new page definitions are in XML format and are stored under WebWeb FilesPage Definitions. Importing pages into the AOT as page definitions allows the pages to be automatically re-created when a Windows SharePoint Services site is created with the Enterprise Portal site definition. The pages can then use the Dynamics AX labels for page titles so that the same page definitions can be used for sites in different languages.

The Import List tool allows you to import KPI lists you create in Office SharePoint Server into the AOT. The new list definitions are in XML format and are stored under WebWeb FilesList Definitions.

You can also deploy the page or list definitions at the individual page or list level, which means that you can import pages and lists created in Windows SharePoint Services (set as the AOT site in AdministrationSetupInternetEnterprise PortalWeb Sites in the Dynamics AX client) into the AOT as page definitions by using the standard Dynamics AX Import and Export utilities. Then you can deploy the newly created or updated page or list definitions to the current Windows SharePoint Services site as Web part pages without having to delete and re-create the site, thereby avoiding problems with data migration from the old site to the new site.

The Import and Deploy Page/List tools use the AOT site setting specified in the Web Sites dialog box as the source or target Windows SharePoint Services site.

Record Context and Encryption

Record context is the interface for passing information through the query string to a Web part page to retrieve a record from Dynamics AX. Enterprise Portal uses record context to locate a record in the Dynamic AX database and display it in a Web form for viewing and editing.

Some of the parameters of the query string to the Enterprise Portal Web part page as record context are listed here:

  • WTID = Table ID

  • WREC = Rec ID

  • WFID = Field ID

  • WKEY = Unique Record KEY (the field identifier and the value of the field for the record to be retrieved)

These parameters are passed either in a query string or in post data on Web pages. If they are passed in clear text, an unauthorized user could view data or perform actions by guessing and manipulating their values. To help secure Enterprise Portal, Dynamics AX encrypts these parameters by default on the front-end Web server, making it impossible to extract or manipulate the parameters. For debugging and Web development, the administrator can turn off the encryption in the Enterprise Portal General tab of the Web Sites dialog box, which is located in AdministrationSetupInternetEnterprise PortalWeb Sites. If the record-level security and other data-level security are already active and no security threats exist, turning off the encryption could result in better performance. However, we strongly recommend that you keep the encryption turned on.

Whether encryption is on or off, the functionality of the Web elements in Enterprise Portal must remain the same. A URL generated for one user can’t be used by any other user. And if the encryption expiration interval is set, a user can’t use the URL generated for him or her after the specified number of days has elapsed. The encryption key is stored in the database and protected by the AOS and .NET Business Connector proxy accounts.

Security

In Enterprise Portal, Dynamics AX security is layered on top of, and depends on, the security of the underlying products and technologies, such as Windows SharePoint Services and IIS. For externally facing sites, communication security and firewall configurations are also important for helping to secure Enterprise Portal.

Enterprise Portal has two configurations in its site definition. The first, referred to as Microsoft Dynamics Public, allows Internet customers or prospective customers to view product catalogs, request customer accounts, and so on. The second, referred to as the Microsoft Dynamics Enterprise Portal, is the complete portal for self-service scenarios involving intranet or extranet users for authenticated employees, vendors, and customers.

The Microsoft Dynamics Public configuration has anonymous authentication enabled in both IIS and Windows SharePoint Services so that anyone on the Web can access it. To connect to Dynamics AX, it uses a built-in Dynamics AX user account named Guest. The Guest account is part of the Enterprise Portal Guest user group, which has limited access to Dynamics AX components necessary for the public site to function. The Enterprise Portal configuration has Integrated Windows authentication or basic authentication over Secure Sockets Layer (SSL) enabled in IIS and Windows SharePoint Services.

This secured site restricts access to users with Active Directory accounts who are configured as Dynamics AX users with Web site access enabled for that particular site by the Dynamics AX administrator. You use the User Relations dialog box (accessed from Administration Setup) to configure users with an employee, vendor, or business relation, or a customer account and contact. Then you can grant them access to Enterprise Portal sites through Site groups for that Windows SharePoint Services Enterprise Portal site.

Both types of Enterprise Portal site use the .NET Business Connector proxy account to establish connections to the AOS. The Windows SharePoint Services application pool must be configured with a Windows domain user account, and this account must be specified as the Dynamics AX .NET Business Connector proxy account for both sites to function. After the connection is established, Enterprise Portal uses either LogonAsGuest or LogonAs, depending on the type of Enterprise Portal site the current user has access to, to activate the Dynamics AX security mechanism. Dynamics AX provides various means and methods to limit user access, such as placing restrictions on individual tables and fields, limiting the availability of application features through configuration keys, and controlling user-level security with security keys.

Enterprise Portal security is role based. This means that you can easily group tasks associated with a business function into a role, such as Sales or Consultant, and assign users to this role to give them the necessary permissions on the Dynamics AX objects to perform those tasks in Enterprise Portal. To allow users access to more functionality, you can assign them to more than one role.

The Enterprise Portal Configuration Wizard imports the predefined user group rights from the Resources node in the AOT. You can easily extend this set of roles by importing the user group permissions into the AOT under the Resources node. You assign a user to a role simply by adding the user to the corresponding user groups.

In addition to the Dynamics AX elements, Enterprise Portal includes Windows SharePoint Services lists and document libraries, which are secured with Windows SharePoint Services site groups. The Dynamics AX user groups play no role in controlling access to the Windows SharePoint Services lists and documents. For consistency and simplicity of the Enterprise Portal roles concept, however, a standard set of Windows SharePoint Services site groups provides access to a specific set of document libraries and lists when the site is created. You can add new roles by modifying the XML file in the AOT under the Web Files node. Based on their Windows SharePoint Services site group membership, Dynamics AX users are granted various levels of permission on these Windows SharePoint Services objects.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset