Vous êtes sur la page 1sur 78

Reporting in Microsoft Dynamics AX 2012 Labs

Walkthrough: Creating an Auto Design Report 8


To define a query.......................................................................................... 9

To create a reporting project ..................................................................... 10

To create an auto design report ................................................................ 10

To apply layout and style templates.......................................................... 11

To add a grouping ...................................................................................... 12

To add a sort order ..................................................................................... 12

To add a document map ............................................................................ 12

Lab 2.2: Create a Report with X++ Business Logic ............................................ 13

Challenge Yourself ....................................................................................... 13

Need a Little Help?....................................................................................... 13

Step by Step: Create a Temporary Table ..................................................... 13

Step by Step: Define a Data Contract Class ................................................. 14

Step by Step: Define a Data Contract Method .............................................. 14

Step by Step: Define a Report Provider Class .............................................. 15

Step by Step: Define a Method to Return the Data to Reporting Services .... 16

Step by Step: Add Business Logic for the Report ......................................... 16

Step by Step: Create a Reporting Project ..................................................... 18

Step by Step: Bind a Report to a Report Data Provider Class ...................... 18

Walkthrough: Customizing Existing Microsoft Dynamics Reports 19


To view the existing report in the application ............................................... 19

To change the development layer................................................................. 20

To open the reporting project in Microsoft Visual Studio.............................. 20

1
Reporting in Microsoft Dynamics AX 2012 Labs

To define a sort order for the account ID ...................................................... 21

To define a parameter to control the display of the account name ............... 21

To import the customized reporting project into Microsoft Dynamics AX ..... 22

To deploy the customized report library to the report server ........................ 22

To verify the results ...................................................................................... 22

Walkthrough: Creating a Report with Parameters 24


To define a query ......................................................................................... 24

To create a reporting project ........................................................................ 25

To create a report ......................................................................................... 25

To add a parameter and filter for selecting customers .................................. 26

To add parameters that determine whether to display phone and fax numbers27

Walkthrough: Creating a Precision Design Report 29


To define the queries .................................................................................... 30

To create a reporting project ........................................................................ 31

To define datasets for the report .................................................................. 31

To configure the parameters ........................................................................ 33

To define a precision design by using SQL Report Designer ......................... 33

To format the report by using SQL Report Designer ..................................... 34

To add totals to the report by using Report Designer ................................... 35

Walkthrough: Creating a Report from an External Data Source 37


To create a reporting project ........................................................................ 38

To define the data source for the report ....................................................... 39

To create the report...................................................................................... 39

2
Reporting in Microsoft Dynamics AX 2012 Labs

Walkthrough: Creating a Drillthrough Report 41


To define a query ......................................................................................... 41

To create a reporting project ........................................................................ 42

To create a top-level report .......................................................................... 42

To create a drillthrough report ..................................................................... 43

To create a parameter that will be used to pass data to the drillthrough report45

To define a filter for the drillthrough report .................................................. 45

To add a report drill through action.............................................................. 45

To preview the drillthrough report ................................................................ 46

Walkthrough: Creating a Matrix Report 47


To define a query ......................................................................................... 47

To create a reporting project ........................................................................ 49

To create a report with a matrix data region ................................................. 49

To apply layout and style templates ............................................................. 50

Walkthrough: Creating a Column Chart Report 51


To define a query ......................................................................................... 52

To create a reporting project ........................................................................ 53

To create a report with a column chart ......................................................... 54

To create and configure report parameters and filters .................................. 56

To apply layout and style templates ............................................................. 58

To switch the format to a bar chart ............................................................... 58

To switch the format to a line chart .............................................................. 58

Lab 3.1 Create a Report Using Cube Data ......................................................... 59

Challenge Yourself ....................................................................................... 59

3
Reporting in Microsoft Dynamics AX 2012 Labs

Need a Little Help?....................................................................................... 59

Step by Step ................................................................................................ 59

Walkthrough: Creating a Cube 62


To create a perspective for the cube ............................................................. 63

To add views to the perspective ................................................................... 63

To add a table to the perspective ................................................................. 63

To set properties on the CustTransTotalSales view........................................ 64

To set properties on the CustTableCube view ............................................... 65

To set properties on the CustPaymModeTable table ..................................... 66

To generate an Analysis Services project ...................................................... 66

To browse the analysis cube data ................................................................. 67

To view cube objects in the generated project.............................................. 67

Lab 4.1 Create a Report to Display in a Role Center .......................................... 69

Challenge Yourself ....................................................................................... 69

Step by Step - Define a Query...................................................................... 69

Step by Step - Create a Reporting Project.................................................... 71

Step by Step - Create a Report .................................................................... 71

Step by Step - Configure Report Parameters ............................................... 72

Step by Step - Apply Layout and Style Templates ........................................ 73

Step by Step - Create Menu Item ................................................................. 74

Step by Step - Create Role Center ............................................................... 75

Step by Step - Add Report to Role Center .................................................... 76

How to: Create a Cue 77


To Create the Menu Item .............................................................................. 77

To Create the Cue......................................................................................... 77

4
Reporting in Microsoft Dynamics AX 2012 Labs

5
Reporting in Microsoft Dynamics AX 2012 Labs

Lab 4.21: Create an Ad Hoc Vendor Report in Excel


Scenario

Role: April, Accounts Payable

Challenge Yourself!
Scenario: April wants to view a list of vendor purchase order invoices in Excel. She creates a new Excel
workbook and uses the Office add-in to create the report from Excel. She wants to view the following
columns in the report:

1. Vendor number
2. Vendor name
3. Transaction date
4. Transaction description
5. Transaction amount

Need a Little Help?


• Click the Add Data icon on the Dynamics AX tab in Excel and select the Vend query.
• Fields from the vendor table including the Vendor account and Name fields are displayed in the
field list.
• Scroll to the bottom of the field list and expand the Vendor transactions table. This table contains
fields including Date, Description, and Amount.
• Add a filter to only extract data from Microsoft Dynamics AX if the Transaction type is
Purchase order.

1
Source: Microsoft Dynamics AX2012 Introduction, chapter 4, page 17

6
Reporting in Microsoft Dynamics AX 2012 Labs

Step by Step

Pre-lab setup
1. Open Dynamics AX and navigate to the Organization Administration Module
2. Open the Document Data Sources form under Setup -> Document Management
3. Add a new entry with the following fields
i. Module: General Ledger
ii. Data source type: query
iii. Data source name: Vend Query
iv. Activated: Checked
4. Close the form

Lab Step by Step


1. Open Microsoft Excel.
2. Click the Add Data icon on the Dynamics AX tab in Excel.
3. Select the check box next to the Vend query.
4. Click OK.
5. Double-click the Vendor account field to add it to the spreadsheet.
6. Double-click the Name field to add it to the spreadsheet.
7. Scroll to the bottom of the list of fields and expand the Vendor transactions table.
8. Double-click the Date field to add it to the spreadsheet.
9. Double-click the Description field to add it to the spreadsheet.
10. Double-click the Amount field to add it to the spreadsheet.
11. Click the Filter button in the Dynamics AX tab in Excel.
12. Click the Add Condition button.
13. Select the Vendor transactions table.
14. Select the Transaction type field.
15. Select Purchase order as the criteria.
16. Click OK.
17. Click the Field Chooser button to return to view mode.
18. Click the Refresh All button to display data in the report.
19. Close Excel.
20. Do not save changes.

7
Reporting in Microsoft Dynamics AX 2012 Labs

Walkthrough2: Creating an Auto Design Report


In this walkthrough, you will create a basic report that displays a list of inventory items. You will use an
auto design report. In this type of report, the report design is automatically generated for you based on
the report data. After you have created the report, you will add some interactive features, such as drill
down capability and a document map. The following illustration shows the report that you will create in
this walkthrough.

2
Source: http://msdn.microsoft.com/en-us/library/cc622728.aspx

8
Reporting in Microsoft Dynamics AX 2012 Labs

Note
The data that displays in your report may vary depending upon the sample data that is available to
you.

This walkthrough illustrates the following tasks:

 Defining a query
 Creating a reporting project
 Creating an auto design report
 Modifying the look of a report
 Adding interactive features to a report

Prerequisites
To complete this walkthrough, you will need:

 Microsoft Dynamics AX with sample data

Note
This walkthrough uses the InventTable table. In order to view data in the report, this table
must be populated with data.

 Microsoft Visual Studio 2010


 Microsoft Visual Studio tools for Microsoft Dynamics AX

Defining a Query
There are several ways to retrieve data for reports. In this walkthrough, you will use a query that is defined
in the AOT within Microsoft Dynamics AX development environment. The following procedure explains
how to define a query that will be used to retrieve item data.

To define a query

1. Open Microsoft Dynamics AX.


2. In the AOT, right-click the Queries node, and then click New Query.
3. Right-click the node for the query, click Rename, and then type Items.
4. Expand the Items node.
5. Right-click the Data Dictionary node, and then click Open New Window.
6. In the new window, expand the Tables node.
7. Locate the InventTable table and drag it onto the Data Sources node for the Items query.
8. Expand the Data Sources node, click the data source that you added in step 7, right-click Fields,
and then click Properties.

9
Reporting in Microsoft Dynamics AX 2012 Labs

9. In the Properties window, set the Dynamic property to Yes.


10. Save the query.

Creating a Reporting Project


Next, you will create a reporting project in Microsoft Visual Studio. When you create a reporting project,
you can choose from two project templates: Report Model and EP Web Application. In this walkthrough,
you will use the Report Model template.

To create a reporting project

1. Open Microsoft Visual Studio.


2. On the File menu, point to New, and then click Project. The New Project dialog box displays.
3. In the Installed Templates pane, click Microsoft Dynamics AX, and in the Templates pane,
clickReport Model.
4. In the Name box, type SampleItemReport. In the Location box, type a location.
5. Click OK.

Creating an Auto Design Report


Now that you have created a reporting project, you are ready to define an auto design report that will
display data from the Items query. The following procedure explains how to create an auto design report.

To create an auto design report

1. In Solution Explorer, right-click the SampleItemReport project, point to Add, and then
click Report.
2. In Model Editor, right-click the new report and click Rename. Type ItemReport as the name.
3. Expand the ItemReport node if it is not already expanded.
4. Right-click the Datasets node, and then click Add Dataset.
5. Select the node for the dataset.
6. In the Properties window, specify the following values.

Property Value
Data Dynamics AX
Source

Data Query
Source
Type

Default Table
Layout

10
Reporting in Microsoft Dynamics AX 2012 Labs

Name Items

Query Click the ellipsis button (…). A dialog box displays where you can select a
query that is defined in the AOT and identify the fields that you want to use.
Select the Items query, expand the All Fields node,
select ItemId, ItemType:NAME, ItemType:LABEL, NameAliasand then
click OK.

7. In Model Editor, select Items > Fields > ItemType.


8. In the Properties window, set the Display Width property to 2.5in.
9. In Model Editor, select the Items node and drag it onto the Designs node. An auto design
namedAutoDesign1 is created for the report.

Modifying the Look of a Report


Next, you will specify layout and style templates for the report. A layout template is used to define the
placement of the headers and footers in a report. Style templates are used to adjust the style settings for
the data regions that are displayed in a report, such as the size of the text, borders, and background color.
Layout and style templates are useful for defining reusable layout and style settings. A template can be
applied to many reports to maintain consistency across reports.

A style template is specific to a data region type. So, if you define a style template for a table, it can only
be applied to table data regions. It cannot be applied to list or matrix data regions. In this example, the
data will be displayed in a table data region since you specified Table for the Default Layout property for
the dataset. The following procedures explain how to apply layout and style templates for the report.

To apply layout and style templates

1. In Model Editor, select the AutoDesign1 node.


2. In the Properties window, set the Layout Template property to ReportLayoutStyleTemplate.
Also, type Inventory items for the Title property.
3. In Model Editor, expand the AutoDesign1 node, and then select the node for the ItemsTable data
region.
4. In the Properties window, set the Style Template property to TableStyleTemplate.
5. From the Model Editor toolbar, click Preview.
6. In the preview window, select the report tab to view the style settings for the report.
7. Close the Preview window.

Adding Interactive Features to a Report


Next, you will add some interactive features to the report. You will start by adding a data grouping to the
report to group items according to the item group. After that, you will change the order that the groups
are displayed. Finally, you will modify the report so that it displays a document map.

11
Reporting in Microsoft Dynamics AX 2012 Labs

To add a grouping

1. In Model Editor, expand the AutoDesign1 node, expand the node for the ItemsTable data region,
and then expand the Data node.
2. Drag the ItemType1 field that is located below the Data node onto the Groupings node.
3. From the Model Editor toolbar node, click Preview.

To add a sort order

1. In Model Editor, expand the ItemsTable data region, right-click Sorting and then click Add Sort.
2. In the Properties window, set the Sort By property to =Fields!ItemType1.Value and the Sort
Orderproperty to Descending.
3. Click the tab for the Preview window to view the report.

The report display will refresh.

To add a document map

1. In Model Editor, select the node for the ItemsTable data region.
2. In the Properties window, set the Data Navigation Style property to DocumentMap.
3. Click the tab for the Preview window to view the report.

The report display will refresh. Notice the document map on the left side of the report. You can
click an item group in the document map and the report displays the data for the items in that
group.

4. In Solution Explorer, right-click the SampleItemReport project and then click


Add SampleItemReportto AOT.

The new report has been added to the AOT. For information about how to integrate new reports into
Microsoft Dynamics AX, see Walkthrough: Integrating New Reports into Microsoft Dynamics AX 3.

3
Source: http://msdn.microsoft.com/en-us/library/cc600454.aspx

12
Reporting in Microsoft Dynamics AX 2012 Labs

Lab 2.24: Create a Report with X++ Business Logic

In this lab you will use a report data provider (RDP) class with business logic to
process data and then display the outcome of the business logic on a report. An
RDP class is an X++ class that is used to access and process data for a Reporting
Services report.

Scenario

Develop a report to display customer data with parameters for account number,
account statement and whether to include tax.

Challenge Yourself

Use the information that is provided in the scenario to develop the report.

Need a Little Help?


1. Create a temporary table
2. Define a report data provider class
3. Define the report parameters
4. Define a method to return data to Reporting Services
5. Add business logic for the report
6. Create a reporting project
7. Bind a report to a report data provider class

Step by Step: Create a Temporary Table


1. Open Microsoft Dynamics AX.
2. Press Ctrl+Shift+W to enter the development environment.
3. In the AOT, expand the Data Dictionary node, right-click the Tables
node, and then click New Table.
4. Right-click the table and click Properties.
5. In the Properties window, set the Name property to
TmpCustTableSample and set the Table Type property to TempDB.
This will define the table as a SQL Server temporary table.
6. Expand the node next to the TmpCustTableSample table so that you
can see the Fields node.
7. Press Ctrl+D to open another AOT window and move the window so
that you can see both AOT windows.

4
Source: Microsoft Dynamics AX 2012 Reporting, Chapter 2

13
Reporting in Microsoft Dynamics AX 2012 Labs

8. In the second AOT, expand the Data Dictionary node, expand the
Extended Data Types node, and drag the following types to the
Fields node in the first AOT window:
o AccountNum
o CustName
o LogisticsAddressing
o CustGroupID
o Phone
o CustInvoiceAccount
o Action Days
o InclTax
9. In the second AOT window, expand the Base Enums node and drag
the CustAccountStatement enumeration to the Fields node of the
first AOT window.

Step by Step: Define a Data Contract Class


1. In the AOT, right-click the Classes node, and then select New Class.
2. Right-click the new class, click Rename, and then enter
"SrsRDPContractSample".
3. Expand SrsRDPContractSample, right-click classDeclaration, and
then click View Code.
4. In code editor, enter the following code in the class declaration to
define the class.

[DataContractAttribute]
public class SrsRDPContractSample
{
AccountNum accountNum;
CustAccountStatement accountStmt;
Boolean inclTax;
}
5. Save the class and close the editor.

Step by Step: Define a Data Contract Method


1. Right-click SrsRDPContractSample, point to New, and then click
Method.
2. Edit the method so that it contains the following code.

[DataMemberAttribute("AccountNum")]
public AccountNum parmAccountNum(AccountNum _accountNum
= accountNum)
{
accountNum = _accountNum;

14
Reporting in Microsoft Dynamics AX 2012 Labs

return accountNum;
}
3. Save the method and close the editor.
4. Right-click SrsRDPContractSample, point to New, and then click
Method.
5. Edit the method so that it contains the following code.

[DataMemberAttribute("CustAccountStatement")]
public CustAccountStatement
parmAccountStmt(CustAccountStatement _accountStmt =
accountStmt)
{
accountStmt = _accountStmt;
return accountStmt;
}
6. Save the method and close the editor.
7. Right-click SrsRDPContractSample, point to New, and then click
Method.
8. Edit the method so that it contains the following code.

[DataMemberAttribute("InclTax")]
public boolean parmInclTax(boolean _inclTax = inclTax)
{
inclTax = _inclTax;
return inclTax;
}
9. Save the method and close the editor.

Step by Step: Define a Report Provider Class


1. In the AOT, right-click the Classes node, and then click New Class.
2. Right-click the new class, click Rename, and then enter
"SrsRDPSampleClass".
3. Expand SrsRDPSampleClass, right-click classDeclaration, and then
click View Code.
4. In the code editor, edit the class so that it contains the following
code.
[
SRSReportQueryAttribute (querystr(Cust)),
SRSReportParameterAttribute(classstr(SrsRDPContractSample))
]
public class SrsRdpSampleClass extends SRSReportDataProviderBase
{
TmpCustTableSample tmpCust;
}

15
Reporting in Microsoft Dynamics AX 2012 Labs

5. Save the class and close the editor.

Step by Step: Define a Method to Return the Data to Reporting Services


1. Right-click SrsRdpSampleClass, point to New, and then click
Method.
2. Edit the method so that it contains the following code.

[SRSReportDataSetAttribute("TmpCust")]
public TmpCustTableSample getTmpCustTable()
{
select * from tmpCust;
return tmpCust;
}
3. Save the method and close the editor.

Step by Step: Add Business Logic for the Report


1. Right-click SrsRdpSampleClass, point to Override method, and then
click processReport.
2. Edit the method so that it contains the following code.

public void processReport()


{ AccountNum accountNumber;
CustAccountStatement custAcctStmt;
boolean boolInclTax;
Query query;
QueryRun queryRun;
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange queryBuildRange;
CustTable queryCustTable;
SrsRdpContractSample dataContract; // Get the query from the runtime using a
dynamic query.
// This base class method reads the query specified in the SSRS
ReportQueryAttribute attribute.
query = this.parmQuery(); // Get the parameters passed from runtime.
// The base class methods read the SRSReportParameterAttribute attribute.
dataContract = this.parmDataContract();
accountNumber = dataContract.parmAccountNum();
custAcctStmt = dataContract.parmAccountStmt();
boolInclTax = dataContract.parmInclTax(); // Add parameters to the query.
queryBuildDataSource =
query.dataSourceTable(tablenum(CustTable)); if(accountNumber)
{
queryBuildRange =

16
Reporting in Microsoft Dynamics AX 2012 Labs

queryBuildDataSource.findRange(fieldnum(CustTable, AccountNum)); if
(!queryBuildRange)
{
queryBuildRange =
queryBuildDataSource.addRange(fieldnum(CustTable, AccountNum));
} // If an account number has not been set, then use the parameter value to set
it.
if(!queryBuildRange.value())
queryBuildRange.value(accountNumber); } if(custAcctStmt)
{ queryBuildRange = queryBuildDataSource.findRange(fieldnum(CustTable,
AccountStatement));
if (!queryBuildRange)
{
queryBuildRange = queryBuildDataSource.addRange(fieldnum(CustTable,
AccountStatement));
} // If an account statement has not been set, then use the parameter value to
set it.
if(!queryBuildRange.value())
queryBuildRange.value(int2str(custAcctStmt)); } if(boolInclTax)
{ queryBuildRange =
queryBuildDataSource.findRange(fieldnum(CustTable, InclTax)); if
(!queryBuildRange)
{
queryBuildRange = queryBuildDataSource.addRange(fieldnum(CustTable,
InclTax));
} // If flag to include tax has not been set, then use the parameter value to set it.
if(!queryBuildRange.value())
queryBuildRange.value(int2str(boolInclTax)); } // Run the query with modified
ranges.
queryRun = new QueryRun(query); ttsbegin;
while(queryRun.next())
{ tmpCust.clear();
queryCustTable = queryRun.get(tablenum(CustTable));
tmpCust.AccountNum = queryCustTable.AccountNum;
tmpCust.CustName = queryCustTable.name();
tmpCust.LogisticsAddressing = queryCustTable.address();
tmpCust.CustGroupId = queryCustTable.CustGroup;
tmpCust.Phone = queryCustTable.phone();
tmpCust.CustInvoiceAccount = queryCustTable.InvoiceAccount;
tmpCust.CustAccountStatement = queryCustTable.AccountStatement;
tmpCust.InclTax = queryCustTable.InclTax;

17
Reporting in Microsoft Dynamics AX 2012 Labs

tmpCust.insert(); }
ttscommit; }

1. Save the method and close the editor.

Step by Step: Create a Reporting Project


1. Open Microsoft Visual Studio.
2. On the File menu, point to New, and then click Project. The New
Project dialog box is displayed.
3. In the Installed Templates pane, click Microsoft Dynamics AX. In the
Templates pane, click Report Model.
4. In the Name box, type SampleRDPReport, and in the Location box,
type a location.
5. Click OK.

Step by Step: Bind a Report to a Report Data Provider Class


1. In Solution Explorer, right-click the SampleRDPReport node, point to
Add and then click Report.
2. In Model Editor, right-click the Report1 node, and then click
Rename.
3. Type "CustomerReport" as the name.
4. Right-click the Datasets node, and then click Add Dataset.
5. In the Properties window, specify the following values.
o Data Source: Dynamics AX
o Data Source Type: Report Data Provider
o Default Layout: Table
o Name: Customer
o Dynamic Filters: True

This setting is for dynamic parameters on the report. Setting the property to
True allows you to filter the report by setting a range on any fields from the data
source table.

6. For the Query property, click the ellipsis button (…). A dialog box
displays where you can select an RDP class that is defined in the
AOT and identify the fields that you want to use. Select the
SrsRDPSampleClass class and click Next. In the Select Fields dialog
box, keep all the check boxes selected, and then click OK.
7. In Model Editor, select the Customer node and drag it onto the
Designs node. An auto design named AutoDesign1 is created for the
report. Based on what you select, the Query property value is
updated. In this case, the query is SELECT * FROM
SrsRDPSampleClass.TmpCust.

18
Reporting in Microsoft Dynamics AX 2012 Labs

Walkthrough5: Customizing Existing Microsoft Dynamics


Reports
In this walkthrough, you will customize the Balance control accounts report which is defined in
theLedgerBalanceControlReport model project that is included with Microsoft Dynamics AX. The Balance
control accounts report displays in the General ledger module. Model projects in Microsoft Dynamics
AX adhere to layered development in the MorphX development environment. This allows model projects
to be customized, upgraded, and patched using the built-in layering support. This walkthrough provides
an example of how to customize existing reports in Microsoft Visual Studio and see those changes in
Microsoft Dynamics AX.

This walkthrough includes the following tasks:

 Viewing the report


 Changing the development layer in Microsoft Dynamics AX
 Customizing reports in Microsoft Visual Studio
 Saving the customizations to Microsoft Dynamics AX
 Deploying customized reports to a report server
 Verifying the results

Prerequisites

To complete this walkthrough, you will need:

 Microsoft Dynamics AX with sample data


 Microsoft Visual Studio 2010
 Microsoft Visual Studio tools for Microsoft Dynamics AX

Viewing the Report

You will begin this walkthrough by viewing the report that you will customize in order to familiarize
yourself with the report. The following procedure explains how to view the Balance control accounts
report within Microsoft Dynamics AX.

To view the existing report in the application

1. Open Microsoft Dynamics AX.


2. Open the Navigation Pane if it is not already open. To do this, click File > View > Navigation
Pane.

5
Source: http://msdn.microsoft.com/en-us/library/cc567629.aspx

19
Reporting in Microsoft Dynamics AX 2012 Labs

3. Select the General ledger module. The Area page for the General ledger module opens.
4. In the Setup section, click Posting > Balance control accounts. The Balance control accounts
form displays.
5. Click the Balance control accounts button and the Balance control accounts report displays.

In this walkthrough, the changes that you will make to this report include adding a sort order to
change the numeric sequence of the main account from ascending to descending. In addition,
you will add a report parameter that will control the display of the account name.

Changing the Development Layer in Microsoft Dynamics AX

Before you customize a report project, be sure that you are working in the correct development layer.
There are several layers that are used for making customizations in Microsoft Dynamics AX. For example,
the supervisor or administrator of an end-user installation might want to make modifications that are
generic to the company. Such modifications are saved in the CUS (CUStomer) layer. For this walkthrough,
you will use the default USR layer. For more information, see Layers. The following steps describe how to
change the layer if you have a valid access code with your license agreement.

To change the development layer

1. Click Start > Control Panel> Administrative Tools> Microsoft Dynamics AX 2012
Configuration.
2. On the Developer tab, select the layer you want to work in from the drop-down list in
the Application object layer to open field, and then click OK.
3. Close and restart the client in the new layer.

Customizing Reports in Microsoft Visual Studio

Next, you will customize the Balance control accounts report in the LedgerBalanceControlReport model
project. When you customize an existing report model project, a copy of the reporting model project for
the layer that you are currently working in is created and opened in Microsoft Visual Studio where it can
be edited and later imported back into the AOT. In the following procedures, you will add a sort order to
sort the main account in a descending sequence. In addition, you will add a report parameter that will
control the display of the account name.

To open the reporting project in Microsoft Visual Studio

1. Open the Microsoft Dynamics AX Development Workspace. If you changed the application object
layer, enter the access code.
2. In the AOT, expand Visual Studio Projects > Dynamics AX Model Projects.
3. Right-click the LedgerBalanceControlReport project, and then click Edit.

The LedgerBalanceControlReport project opens in Microsoft Visual Studio with


theLedgerBalanceControl report open in the Model Editor.

20
Reporting in Microsoft Dynamics AX 2012 Labs

To define a sort order for the account ID

1. In Model Editor, expand the LedgerBalanceControl node if it is not already expanded.


2. Expand the Designs node, expand the Reports node, and then expand
theLedgerBalanceControlDSTable node. This is an Auto Design report with a table definition.
3. Right-click the Sorting node, and then click Add Sort.
4. Select the node for the sort order.
5. In the Properties window, specify the following property values.

Property Description
Name SortMainAccountID

Sort By =Fields!MainAccount_MainAccountId.Value

Sort Order Descending

To define a parameter to control the display of the account name

1. In Model Editor, right-click the Parameters node for the report, and then click Add Parameter.
TheParameters node is located after the Data Methods node.
2. Select the node for the parameter.
3. In the Properties window, specify the following property values.

Property Description
Data Type Boolean

Default Value True

Name IncludeAccountName

Prompt String Include account name

4. From LedgerBalanceControl > Designs > Report > LedgerBalanceControlDSTable > Data,
select theAccountName field.
5. In the Properties window, type =iif(Parameters!IncludeAccountName.Value = True, True,
False) for theVisible property.
6. To preview the report, in the Model Editor toolbar, click Preview.

Note

21
Reporting in Microsoft Dynamics AX 2012 Labs

Notice that a parameter checkbox was added called Include account name and by default
the checkbox is marked.

7. Click the Report tab to view the report. Verify the changes that you made to the report.
8. Close the Preview window.

Importing Customizations into Microsoft Dynamics AX

Next, you will add the report project into Microsoft Dynamics AX. During the add process, all required
project items are identified. These project items are validated, packaged, and then added to the AOT. The
customizations made in this walkthrough will be added to the current development layer.

To import the customized reporting project into Microsoft Dynamics AX

 In Solution Explorer, right-click the LedgerBalanceControlReport reporting project, and then


click Add LedgerBalanceControlReport to AOT.

When you open Microsoft Dynamics AX, you will notice that the LedgerBalanceControlReport
project is now updated in the current customization layer. If you do not see this, close the
Microsoft Dynamics AX client, and then reopen it.

Deploying Customized Reports to a Report Server

Next, you will deploy the customized LedgerBalanceControlReport project to the report server so that the
customizations made to the reports are available to the application.

To deploy the customized report library to the report server

1. In the AOT, click the SSRS Reports node and the Reports node.
2. Right-click the LedgerBalanceControl node for the layer that you made the customization, for
example,LedgerBalanceControl(usr). Then click Deploy.
3. Review any messages logged during the deployment process, and then close the Infolog form.

Verifying the Results

Next, you will verify that the customized report now displays in Microsoft Dynamics AX.

To verify the results

1. In the Navigation Pane, select the General ledger module.


2. In the Setup section, click Posting > Balance control accounts. The Balance control accounts
form displays.

22
Reporting in Microsoft Dynamics AX 2012 Labs

3. Click the Balance control accounts button. Notice the parameter that controls whether to display
the account name has been added.
4. Unmark the checkbox to display the account name and then click OK.

Notice that the account IDs are now in descending order and the main account name does not
display.

23
Reporting in Microsoft Dynamics AX 2012 Labs

Walkthrough6: Creating a Report with Parameters


In this walkthrough, you will create a report that displays customer data. You will add parameters to the
report to allow users to filter the data that displays in the report.

This walkthrough illustrates the following tasks:

 Defining a query
 Creating a reporting project
 Creating a report
 Adding parameters to a report

Prerequisites

To complete this walkthrough, you will need:

 Microsoft Dynamics AX with sample data

Note

This walkthrough uses the CustTable table. In order to view data in the report, this table
must be populated with data.

 Microsoft Visual Studio 2010


 Microsoft Visual Studio tools for Microsoft Dynamics AX

Defining a Query

There are several ways to retrieve data for reports. In this walkthrough, you will use a query that is defined
within the Microsoft Dynamics AX development workspace. The following procedure explains how to
define the query that will be used to retrieve data for the report.

To define a query

1. Open Microsoft Dynamics AX.


2. In the AOT, right-click the Queries node, and then click New Query.
3. Right-click the node for the query, click Rename, and then type CustomerList.
4. Expand the node for the CustomerList query.

6
Source: http://msdn.microsoft.com/en-us/library/cc636713.aspx

24
Reporting in Microsoft Dynamics AX 2012 Labs

5. Right-click the Data Dictionary node, and then click Open New Window.
6. In the new window, expand the Tables node.
7. Locate the CustTable table and drag it onto the Data Sources node for the CustomerList query.
8. Expand the CustomerList > Data Sources > CustTable_1 and then click Fields. In the Properties
window, set the Dynamic property to Yes.
9. Save the query.

Creating a Reporting Project

Next, you will create a reporting project in Microsoft Visual Studio. When you create a Microsoft Dynamics
AX project, you can choose from two project templates: Report Model and EP Web Application. In this
walkthrough, you will use the Report Model template.

To create a reporting project

1. Open Microsoft Visual Studio.


2. On the File menu, point to New, and then click Project. The New Project dialog box displays.
3. In the Installed Templates pane, click the Microsoft Dynamics AX node, and in
the Templates pane, click Report Model.
4. In the Name box, type SampleCustomerListReport, and in the Location box, type a location.
5. Click OK.

Creating a Report

Now that you have created a reporting project, you are ready to create the report. The following
procedure explains how to create the report.

To create a report

1. In Solution Editor, right-click the SampleCustomerListReport project, point to Add, and then
clickReport.
2. In Model Editor, click the report and type CustomerList as the name.
3. Right-click the Datasets node, and then click Add Dataset.
4. Select the node for the dataset.
5. In the Properties window, specify the following values.

Property Value
Data Dynamics AX
Source

Data Query
Source

25
Reporting in Microsoft Dynamics AX 2012 Labs

Type

Default Table
Layout

Dynamic False
Filters

Name Customers

Query Click the ellipsis button (…). A dialog box displays where you can select a
query that is defined in the AOT and identify the fields that you want to use.
Select the CustomerListQuery and then click Next. In the Select
Fields window, expand the All Fields node and then select
the AccountNum field. Expand the All Display Methods and select
the Address,Name, Phone and TeleFax fields. Click OK.

6. In Model Editor, select the Customers node and drag it onto the Designs node. An auto design
namedAutoDesign1 is created for the report.
7. Select the AutoDesign1 node.
8. In the Properties window, set the LayoutTemplate property to ReportLayoutStyleTemplate.
Also, typeCustomer list for the Title property.
9. In Model Editor, expand the AutoDesign1 node, and then select the node for the table data
region.
10. In the Properties window, set the Style Template property to TableStyleTemplate.

Adding Parameters to a Report

Next, you will add parameters to the report. First, you will add a parameter and a filter that uses the
parameter to allow users to select a customer for which to display data. Then, you will add parameters
that will be used to determine whether to display the phone and fax numbers for the customers in the
report. The following procedures explain how to define the parameters for the report.

To add a parameter and filter for selecting customers

1. In Model Editor, right-click the Parameters node for the report, and then click Add Parameter.
2. Select the node for the parameter.
3. In the Properties window, specify the following values.

Property Value

26
Reporting in Microsoft Dynamics AX 2012 Labs

Multi False
Value

Name CustomerName

Prompt Customers:
String

Values Click the ellipsis button (...). In the dialog box that displays, click the From
Dataset radio button. Select Customers from the drop-down menu for Dataset.
Select name from the drop-down menu for Value Field, and select name from
the drop-down menu for Label Field. Click OK.

4. Expand the AutoDesign1 node, and then expand the node for the table data region.
5. Right-click the Filters node, and then click Add Filter.
6. Select the node for the filter.
7. In the Properties window, specify the following values.

Property Value
Expression =Fields!name.Value

Name SelectCustomers

Operator In

Value =Parameters!CustomerName.Value

8. To preview the report, right-click the AutoDesign1 node in Model Editor, and then click Preview.
The parameter that you defined displays in the Parameters window.
9. To use the parameter, select a customer name from the list that displays for the parameter, and
then click the Report tab. The data for the selected customers displays.
10. Close the Preview window

To add parameters that determine whether to display phone and fax numbers

1. In Model Editor, right-click the Parameters node, and then click Add Parameter.
2. Select the node for the parameter.
3. In the Properties window, specify the following values.

Property Value
Data Boolean

27
Reporting in Microsoft Dynamics AX 2012 Labs

Type

Name DisplayPhoneNumber

Prompt Display phone number?


String

Values Click the ellipsis button (...). In the dialog box that displays, click the Non-
queried radio button. In the first row in the table, type True in
the Value column and type Yes in the Labelcolumn. In the second row,
type False in the Value column and type No in the Labelcolumn. Click OK.

4. In Model Editor, right-click the Parameters node, and then click Add Parameter.
5. Select the node for the parameter.
6. In the Properties window, specify the following values.

Property Value
Data Boolean
Type

Name DisplayTeleFaxNumber

Prompt Display fax number?


String

Values Click the ellipsis button (...). In the dialog box that displays, click the Non-
queried radio button. In the first row in the table, type True in
the Value column and type Yes in the Labelcolumn. In the second row,
type False in the Value column and type No in the Labelcolumn. Click OK.

7. In Model Editor, expand the AutoDesign1 node, expand the node for the table data region, and
then expand the Data node.
8. Select the Phone field, and type the
expression =IIf(Parameters!DisplayPhoneNumber.Value=True, True, False) for the Visible property
in the Properties window.
9. Select the TeleFax field, and type the
expression =IIf(Parameters!DisplayTeleFaxNumber.Value=True, True, False) for
the Visible property in the Properties window.
10. To preview the report, right-click the AutoDesign1 node in Model Editor, and then click Preview.
The new parameters display in the Parameters window along with the previous parameter. To
use the parameters, select one or more customers and specify Yes or No for the two display
parameters. The data for the selected customers displays.
11. Close the Preview window

28
Reporting in Microsoft Dynamics AX 2012 Labs

Walkthrough7: Creating a Precision Design Report


In this walkthrough, you will create a vendor invoice report. You will use SQL Report Designer to create a
precision design for the report. The following illustration shows the report that you will create in this
walkthrough.

Note

The data that displays in your report may vary depending on the sample data that is available to
you.

This walkthrough illustrates the following tasks:

 Defining queries
 Creating a reporting project
 Creating a precision design report using SQL Report Designer

Prerequisites

To complete this walkthrough, you will need:

7
Source: http://msdn.microsoft.com/en-us/library/cc624720.aspx

29
Reporting in Microsoft Dynamics AX 2012 Labs

 Microsoft Dynamics AX with sample data

Note

In this walkthrough, you will use the VendInvoiceJour and VendInvoiceTrans tables.
Therefore, these tables must be populated with data.

 Microsoft Visual Studio 2010


 Microsoft Visual Studio tools for Microsoft Dynamics AX

Defining Queries

There are several ways to retrieve data for reports. In this walkthrough, you will create queries in the
Microsoft Dynamics AX development workspace. The following procedure explains how to define the
queries that will be used to retrieve data for a vendor invoice report.

To define the queries

1. Open Microsoft Dynamics AX.


2. In the AOT, right-click the Queries node, and then click New Query.
3. Right-click the node for the query, click Rename, and then type InvoiceJournal.
4. Expand the node for the InvoiceJournal query.
5. Right-click the Data Dictionary node, and then click Open New Window.
6. In the new window, expand the Tables node.
7. Locate the VendInvoiceJour table and drag it onto the Data Sources node for the query.
8. Expand the node for the VendInvoiceJour data source.
9. Select the Fields node, in the Properties window, set the Dynamic property to Yes.
10. Right-click the Ranges node, and then click New Range.
11. Right-click the VendGroup node and then click Properties. Select the node for the range, and in
theProperties window, set the Field property to InvoiceId.
12. In the AOT, right-click the Queries node, and then click New Query.
13. Right-click the node for the query, click Rename, and then type InvoiceTransaction.
14. Expand the node for the InvoiceTransaction query.
15. Locate the VendInvoiceTrans table and drag it onto the Data Sources node for the query.
16. Expand the node for the VendInvoiceTrans data source.
17. Select the Fields node, in the Properties window, set the Dynamic property to Yes.
18. Right-click the Ranges node, and then click New Range.
19. Select the node for the range, and in the Properties window, set the Field property to InvoiceId.
20. Save the queries.

Creating a Reporting Project

30
Reporting in Microsoft Dynamics AX 2012 Labs

Next, you will create a reporting project in Microsoft Visual Studio. When you create a Microsoft Dynamics
AX project, you can decide from two project templates: Report Model and EP Web Application. In this
walkthrough, you will use the Report Model template.

To create a reporting project

1. Open Microsoft Visual Studio.


2. On the File menu, click New, and then click Project. The New Project dialog box is displayed.
3. In the Installed Templates pane, click the Microsoft Dynamics AX node. In the Templates pane,
clickReport Model.
4. In the Name box, type SampleVendorInvoiceReport, and in the Location box, type a location.
5. Click OK.

Creating a Precision Design Report By Using SQL Report


Designer

Now that you have created a reporting project, you are ready to create a precision design report to
display the data returned by the queries that you created in Microsoft Dynamics AX. To do this, you will
first define datasets for the report. Then, you will configure the parameters that are created for the
datasets. Finally, you will use SQL Report Designer to define the report layout.

To define datasets for the report

1. In Solution Explorer, rick-click the SampleVendorInvoiceReport project, point to Add, and then
clickReport.
2. In Model Editor, right-click the Report1 node, and then click Rename.
3. Type VendorInvoiceReport.
4. Right-click the Datasets node for the report, and then click Add Dataset.
5. Select the node for the dataset.
6. In the Properties window, specify the following property values.

Property Value
Dynamic False
Filters

Data Dynamics AX
Source

Data Query
Source
Type

31
Reporting in Microsoft Dynamics AX 2012 Labs

Name InvoiceJournalDataset

Query Click the ellipsis button (…). A dialog box displays where you can select a query
that is defined in the AOT and identify the fields that you want to use. Select
the InvoiceJournalquery, click Next, and then expand the All Fields node.
Select the PurchId, OrderAccount,InvoiceAccount, InvoiceId, InvoiceDate,
and DueDate fields. Click OK.

7. In Model Editor, right-click the Datasets node for the report, and then click Add Dataset.
8. Select the node for the dataset.
9. In the Properties window, specify the following property values.

Property Value
Dynamic False
Filters

Data Dynamics AX
Source

Data Query
Source
Type

Name InvoiceTransactionDataset

Query Click the ellipsis button (…). A dialog box displays where you can select a
query that is defined in the AOT and identify the fields that you want to use.
Select theInvoiceTransaction query, click Next, and then expand the All
Fields node. Select theItemId, Name, Qty, PurchPrice,
and LineAmount fields. Click OK.

10. Since the queries that are used for both of the datasets have a range based on the InvoiceId field,
dataset and report parameters are added to the report in Model Editor. The following table
describes dataset and report parameters.

Parameter Description
Dataset Dataset parameters are generated when a dataset is based on
parameter the Query property and theDynamic Filters property of the dataset.
 When you define a dataset where the Dynamic Filters property is set
to True, a single dataset parameter is created to transport the dynamic
filters that are set at runtime for the report.

32
Reporting in Microsoft Dynamics AX 2012 Labs

 When the Dynamic Filters property is set to False, zero to many


parameters are created based on the Query property of the dataset.

Report Report parameters are defined globally for the report. They are generated if
parameter the report query includes parameters, or they can be created manually. After a
report parameter is created, you must set properties that identify it and that
control how it is used in the report. The naming convention of report
parameters the DatasetName_FieldName.

11. Parameters of this kind are added when you bind the query to a dataset. In this example, both
report parameters represent the same field. Therefore, you will set up the report to use one of the
report parameters as a design parameter and both of the dataset parameters for
the InvoiceID field will reference the design parameter.

To configure the parameters

1. In Model Editor, expand the Parameters node for the report.


2. Select the InvoiceJournalDataset_InvoiceId parameter.
3. In the Properties window, type Invoice ID: for the Prompt String property.
4. Right-click the InvoiceTransactionDataset_InvoiceId parameter and then click Delete.
5. Expand Datasets > InvoiceTransactionDataset > Parameters, and then select InvoiceID. In the
Properties window, set the Report parameter to InvoiceJournalDataset_InvoiceId. Now both
InvoiceID dataset parameters are set to InvoiceJournalDataset_InvoiceId.

After the datasets and parameters are defined, you can start defining the report layout. You create a
report layout by dragging and dropping data regions, text boxes, images, and other items that you want
to include in your report to the design surface.

To define a precision design by using SQL Report Designer

1. In Model Editor, right-click the Designs node for the report, point to Add, and then
click Precision Design.

The Precision Design window is displayed with an empty report. The Report Data window that
contains the datasets that you defined in the model appears on the left.

2. In the Toolbox pane, click the Table element and drag it to the design surface. Report Designer
draws a table data region with three columns.

Note

The Toolbox may appear as a tab on the left side of the Report Data pane. If
the Toolbox is not visible, from the View menu, click Toolbox.

33
Reporting in Microsoft Dynamics AX 2012 Labs

3. From the Report Data pane, drag the PurchId field to the first column in the table.

When you drop the field into the first column, two things occur. First, the data cell will display the
field name, known as the field expression, in brackets: [PurchId]. Second, a column header value is
automatically added to Header row, just above the field expression. By default, the column is the
name of the field. You can select the Header row text and type a new name.

4. Press Ctrl-S to save the design.


5. Click the Preview tab. The report displays in Preview view.

Previewing a report enables you to easily view the rendered report without having to deploy the
report to a report server. You can preview your report frequently during design time.

6. Click the Design tab.


7. Right-click the table, point to Insert Column, and then click Right. Repeat this until there are five
columns in the table.
8. Drag the OrderAccount, InvoiceAccount, InvoiceDate, and DueDate to the columns of the table on
the design surface.
9. In the Toolbox pane, select the Table element, and drag it below the previous table.
10. Right-click the table, point to Insert Column, and then click Right. Repeat this until there are five
columns in the table.
11. Drag the ItemId, Name, Qty, PurchPrice, and LineAmount fields
from InvoiceTransactionDataset in the Report Data window to the columns that you created.
The following diagram shows the two table data regions that have been populated with fields.

12. Save the report.


13. To preview the report design, click the Preview tab in SQL Report Designer. Type an invoice ID in
theParameters tab, and then click the Report tab to view the report.

You have successfully added a Table data region to your report, added fields to the data region, and
previewed your report. In the next section, you will format the report.

To format the report by using SQL Report Designer

1. Click the Design tab.


2. In the Toolbox pane, select the Textbox element and drag it to the upper-left side of the report.
3. Right-click the text box and then click Text Box Properties.
4. In the Value: property, type Invoice specification.

34
Reporting in Microsoft Dynamics AX 2012 Labs

5. Click Font, in the Font field, select Tahoma.


6. In the Size field, select 14pt.
7. Click OK. You may need to adjust the size of the text box.
8. In the Toolbox pane, select the Line element and draw a line below the text box that you added
in the previous step.
9. Select the line, and in the Properties window, set the LineWidth property to 2pt and
set LineColorproperty to Blue.
10. In the first table, right-click the [InvoiceDate] field expression and then click Text Box Properties.
11. Click Number, and then in the Category field, select Date.
12. In the Type box, select January 31, 2000.
13. Click OK.
14. In the first table, right-click the [InvoiDueDate] field expression and repeat the previous steps to
format the date.
15. In the first table, click the row handle for the first row to select the field headers, in
the Propertieswindow, expand the Font property and set the FontFamily to Tahoma and
the FontWeight to Bold.
16. In the first table, click the row handle for the second row to select the field expressions, in
theProperties window, expand the Font property and set the FontFamily to Tahoma.
17. In the second table, click the row handle for the first row to select the field headers, in
the Propertieswindow, expand the Font property and set the FontFamily to Tahoma and
the FontStyle to Italic.
18. In the second table, click the row handle for the second row to select the field expressions in the
second row, in the Properties window, expand the Font property and set
the FontFamily to Tahoma.
19. In the first table, select the [OrderAccount] field expression, in the Properties window, expand
the Sizeproperty, and then set the Width to 2in.
20. In the second table, select the [Name] field expression, in the Properties window, expand
the Sizeproperty, and then set the Width to 2in.
21. Select the second table, and in the Properties window, set the BackgroundColor to Lavender.
22. In the second table, right-click a cell in the first row, point to Insert Row, and then click Above.
23. In the new row, select the fieds, right-click the selection, and then click Merge Cells.
24. Select the merged cell, and in the Properties window, set the Font property to Tahoma, 10pt,
Default, Bold, Default, set the TextAlign property to Center, and in the field type Item details.
25. Select the [PurchPrice] and the [LineAmount], and in the Properties window, type c for
the Formatfield. This will format the values in these cells as currency.

You have successfully formatted your report. In the next section, you will add totals to the report.

To add totals to the report by using Report Designer

1. In the second table, right-click the second row, click Insert Row -> Outside Group Below.
2. Repeat the previous step so you have two rows below the second row in the table.
3. In the first added row, select the first four cells, right-click the selected cells and then click Merge
Cells.
4. Select the merged cell and type Sales tax:. In the Properties window, set the TextAlign property
toRight.

35
Reporting in Microsoft Dynamics AX 2012 Labs

5. Select the last cell in the first footer row, type =Sum(Fields!LineAmount.Value*.07), set the
type c for theFormat property.
6. In the last footer row, merge the first four cells and type Total amount due:.
7. Select the merged cell, and in the Properties window, set the FontWeight property to Bold, and
set theTextAlign property to Right.
8. Select the last cell in the last footer row, type =Sum(Fields!LineAmount.Value*1.07) for
the Valueproperty, set the FontWeight property to Bold, and type c for the Format property.
9. Select the cells that display the values for sales tax and total amount due, and in
the Propertieswindow, set the BorderColor property to DimGrey.
10. Save and preview the report.

You have now successfully created a precision design report by using the Microsoft Dynamics AX tools for
Visual Studio and Report Designer. You can now create a menu item to display the report in the Microsoft
Dynamics AX client.

36
Reporting in Microsoft Dynamics AX 2012 Labs

Walkthrough8: Creating a Report from an External Data


Source
A data source is a facility for storing data. You can use the predefined Dynamics AX data source, which
connects to the Microsoft Dynamics AX application database. Or, you can define an external data source
to retrieve data from a different location. In this walkthrough, you will create a report from data that is
stored in a separate SQL database that you create. In your report model, you will define an external data
source that specifies the connection information for the database so that you can retrieve data from that
database to display in your report.

This walkthrough illustrates the following tasks:

 Creating report data


 Creating a reporting project
 Defining an external data source
 Creating a report
 Modifying the look of a report

Prerequisites

To complete this walkthrough, you will need:

 Microsoft Dynamics AX SDK


 Microsoft Visual Studio 2010
 Microsoft Dynamics AX tools for Microsoft Visual Studio

Creating Report Data

You will start by creating a SQL database that will hold the data for your report. You will execute a set of
SQL statements to create a database and a table that is populated with data.

To create the data


1. Open SQL Server Management Studio.
2. When prompted to connect to a server, be sure to specify Database Engine for
the Server type field.
3. In SQL Server Management Studio, click the New Query button to display the query
editor window.

8
Source: http://msdn.microsoft.com/en-us/library/cc551711.aspx

37
Reporting in Microsoft Dynamics AX 2012 Labs

4. Copy the following SQL statements into the query editor.

SQL

CREATE DATABASE AXSampleData;


GO
USE AXSampleData
CREATE TABLE [dbo].[Item](
[ItemID] [int] NOT NULL,
[Name] [nvarchar](50) NULL,
[Description] [nvarchar](50) NULL,
[Cost] [numeric](18, 2) NULL,
[SellingPrice] [numeric](18, 2) NULL,
[Status] [int] NULL)
INSERT INTO Item VALUES (1734, 'Clamp', 'Workbench Clamp', 12.48, 17.99, 0);
INSERT INTO Item VALUES (1258, 'Hammer', '10 oz Hammer', 7.25, '11.99', 0);
INSERT INTO Item VALUES (2783, 'Hammer', '12 oz Hammer', 9.50, 15.89, 2);
INSERT INTO Item VALUES (1983, 'Saw', 'Wooden Handle Saw', 7.89, 11.99, 1);
INSERT INTO Item VALUES (4920, 'Nails', '10 oz Flat Top Nails', 3.45, 4.99, 0)
;
INSERT INTO Item VALUES (6728, 'Screwdriver', 'Standard Screwdriver', 2.75, 3.
99, 1);
INSERT INTO Item VALUES (9283, 'Nails', 'Roofing Nails 5 lbs', 12.45, 15.99, 0
);
INSERT INTO Item VALUES (4829, 'Tape Measure', '25 foot Tape Measure', 12.87,
16.99, 2);
INSERT INTO Item VALUES (2893, 'Nails', 'Finish Nails', 3.90, 5.59, 1);
5. Click Execute to execute the SQL statements.
6. Verify that the database and table have been added to your server.
7. Close SQL Server Management Studio.

Creating a Reporting Project

Next, you will create a reporting project in Microsoft Visual Studio. When you create a Microsoft Dynamics
AX project, you can choose from two project templates: Report Model and EP Web Application. In this
walkthrough, you will use the Report Model template.

To create a reporting project

1. Open Microsoft Visual Studio.


2. On the File menu, click New, and then click Project. The New Project dialog box displays.
3. In the Installed Templates pane, click the Microsoft Dynamics AX node, and in
the Templates pane, click Report Model.
4. In the Name box, type SampleExternalDataSourceReport, and in the Location box, type a
location.

38
Reporting in Microsoft Dynamics AX 2012 Labs

5. Click OK.

Defining a Data Source

A data source contains information about a connection to a database. This includes information such as
the server name, the database name, and user credentials. Next, you will define a new data source in your
model so that you can access the data in the AXSampleData database.

To define the data source for the report

1. In Solution Explorer, right-click the SampleExternalDataSourceReport project, point to Add, and


then click Report Data Source.
2. In Model Editor, select the node for the data source.
3. In the Properties window, specify the following values.

Property Value
Connection Server=[YourServerName];Database=AXSampleData;Integrated
String Security=SSPI
Note

Insert the name of your server for [YourServerName]. It must be the name of the
server that contains the database that you created in the previous procedure. In this
statement, Security Support Provider Interface (SSPI) is using Microsoft Windows
user credentials for authentication. You may need to use a different authentication
mode depending upon how you have set up your SQL Server instance.

Name AXSampleData

Provider SQL

Creating a Report

Next, you will create a report to display item data. You will start by creating a query for the report dataset
using a TSQL statement. After you define the dataset, you will format the data. The status of an item takes
on an integer value between 0 and 2. The value 0 means that the item is In Stock. The value 1 means that
the item is On Order. The value 2 means that the item is Back Ordered. You will add an expression to the
report to convert the integer value to text so that it is easy to read. You will also format the cost and
selling price as currency. The following procedure explains how to create the report.

To create the report

1. In Solution Explorer, right-click the SampleExternalDataSourceReport project, point to Add, and


then click Report.

39
Reporting in Microsoft Dynamics AX 2012 Labs

2. In Model Editor, right-click the Report1 node, and then click Rename.
3. Type ItemListReport as the name.
4. Right-click the Datasets node, and then click Add Dataset.
5. Select the node for the dataset.
6. In the Properties window, specify the following values.

Property Value
Data Source AXSampleData

Data Source Type Query

Default Layout TopDownList

Name Item

Query Select ItemID, Name, Description, Cost, SellingPrice, Status from Item

7. In Model Editor, select the Cost node, and in the Properties window, set the Format
String property toCurrency.
8. Select the SellingPrice node, and in the Properties window, set the Format String property
toCurrency.
9. Drag the Item dataset onto the Designs node for the report. This creates an auto design for the
report based on the data in the dataset.
10. Expand the AutoDesign1 node, expand the node for the list data region, and then expand
the Datanode.
11. Select the Status node, and in the Properties window, click <Expression…> from the drop-down
menu for the Expression property.

The Edit Expression dialog box displays. In this dialog box, you will enter an expression so that
text displays for the item status.

12. In the Edit Expression dialog box, type the following expression =Switch(Fields!Status.Value = 0,
“In Stock”, Fields!Status.Value = 1, “On Order”, Fields!Status.Value = 2, “Back Ordered”), and then
click OK.
13. In Model Editor, select the AutoDesign1 node.
14. In the Properties window, set the Layout Template property
to ReportLayoutStyleTemplate and typeInventory items for the Title property.
15. In Model Editor, expand the AutoDesign1 node, and then select the list data region.
16. In the Properties window, set the Style Template property to ListStyleTemplate.
17. To preview the layout of the report, right-click the AutoDesign1 node, and then click Preview.

Next, you can add a menu item to display the report in the Microsoft Dynamics AX client or add
additional interactive features to the report.

40
Reporting in Microsoft Dynamics AX 2012 Labs

Walkthrough9: Creating a Drillthrough Report


In this walkthrough you will create a drillthrough report. A drillthrough report is a report that a user opens
by clicking a linked item in another report. It allows users to drill through to additional data.

This walkthrough illustrates the following tasks:

 Defining a query
 Creating a reporting project
 Creating a top-level report and a drillthrough report
 Adding a report drill through action

Prerequisites

To complete this walkthrough, you will need:

 Microsoft Dynamics AX with sample data

Note

This walkthrough uses the AssetTable table. In order to view data in the reports, this table
must be populated with data.

 Microsoft Visual Studio 2010


 Visual Studio tools for Microsoft Dynamics AX

Defining a Query

There are several ways to retrieve data for reports. In this walkthrough, you will use a query that is defined
within the Microsoft Dynamics AX development environment. This query will be based on
the AssetTable table. Both the top-level report and the drillthrough report will be based on the same
query; however, the drillthrough report will display more fields to show detailed information about a
selected asset. The following procedure explains how to define the query that will be used to retrieve data
for the reports.

To define a query

1. In Microsoft Dynamics AX, open a New Development Workspace.

9
Source: http://msdn.microsoft.com/en-us/library/cc639019.aspx

41
Reporting in Microsoft Dynamics AX 2012 Labs

2. In the AOT, right-click the Queries node, and then click New Query.
3. Right-click the node for the query, click Rename, and then type Assets.
4. Expand the node for the Assets query.
5. Right-click the Data Dictionary node, and then click Open New Window.
6. In the new window, expand the Tables node.
7. Locate the AssetTable table and drag it onto the Data Sources node for the Assets query.
8. In the Assets query node, expand the Data Sources node, expand the AssetTable_1 node, select
theFields node, in the Properties window, set the Dynamic property to Yes.
9. Save the query.

Creating a Reporting Project

Next, you will create a reporting project in Microsoft Visual Studio. When you create a reporting project,
you can choose from two project templates: Report Model and EP Web Application. In this walkthrough,
you will use the Report Model template.

To create a reporting project

1. Open Microsoft Visual Studio.


2. On the File menu, point to New, and then click Project. The New Project dialog box displays.
3. In the Installed Templates pane, click Microsoft Dynamics AX, and in the Templates pane,
clickReport Model.
4. In the Name box, type SampleDrillthroughReport. In the Location box, type a location.
5. Click OK.

Creating Reports

Next, you will create two reports: a top-level report and a drillthrough report. The top-level report will be
a basic list of all assets in the AssetTable table. The drillthrough report will be a more detailed report that
will display information about the asset that is selected in the top-level report. You will add a parameter
and filter to the drillthrough report. The parameter will be used to pass data from the top-level report to
the drillthrough report. The filter will filter the data in the drillthrough report based on the value of the
parameter. The following procedures explain how to create the reports.

To create a top-level report

1. In Solution Explorer, right-click the SampleDrillThroughReports project, point to Add and then
clickReport.
2. In the Properties window, for the Name property type AssetList. The model displays in Model
Editor with a report named AssetList.
3. In Model Editor, right-click the Datasets node, and then click Add Dataset.
4. Select the node for the dataset.
5. In the Properties window, specify the following values.

42
Reporting in Microsoft Dynamics AX 2012 Labs

Property Value
Data Dynamics AX
Source

Data Query
Source
Type

Default Table
Layout

Dynamic False
Filters

Name Assets

Query Click the ellipsis button (…). A dialog box displays where you can select a
query that is defined in the AOT and identify the fields that you want to use.
Select the Assets query, clickNext, expand the node for All Fields, and then
select the AssetId, and Name fields. When you are finished selecting the
fields, click OK.

6. In Model Editor, select the Assets dataset node and drag it onto the Designs node. An auto
design named AutoDesign1 is created for the report.
7. Select the AutoDesign1 node.
8. In the Properties window, set the LayoutTemplate property
to ReportLayoutStyleTemplate and typeAssets for the Title property.
9. In Model Editor, expand the AutoDesign1 node, and then select the node for
the AssetsTable data region.
10. In the Properties window, set the style template to TableStyleTemplate and type Asset list for
the Titleproperty.

To create a drillthrough report

1. In Solution Explorer, right-click the SampleDrillThroughReports project, point to Add, and then
clickReport.
2. In the Properties window, for the Name property type AssetDetails. The model displays in Model
Editor with a report named AssetDetails.
3. Right-click the Datasets node, and then click Add Dataset.
4. Select the node for the dataset.
5. In the Properties window, specify the following values.

Property Value

43
Reporting in Microsoft Dynamics AX 2012 Labs

Data Dynamics AX
Source

Data Query
Source
Type

Default TopDownList
Layout

Dynamic False
Filters

Name Details

Query Click the ellipsis button (…). A dialog box displays where you can select a query
that is defined in the AOT and identify the fields that you want to use. Select
the Assets query, clickNext, expand the node for All Fields, and then select
the AssetId, Name, SerialNum,InsuredValue, Make, Model, AssetReplaceCost,
and TechInfo1 Fields. When you are finished selecting the fields, click OK.

6. In Model Editor, in the Details dataset, expand the Fields node, select the node for
theAssetReplaceCost field, and in the Properties window, set the FormatString property
to Currency.
7. In the Fields node, select the node for the InsuredValue field, and in the Properties window, set
theFormatString property to Currency.
8. In the Fields node, select the node for the Name field and then click the Move up button on the
Model Editor toolbar until it is first in the list.

Note

You can also press ALT+UP ARROW or ALT+DOWN ARROW to move an element up
or down in a collection in Model Editor.

9. Select the Details node and drag it onto the Designs node. An auto design
named AutoDesign1 is created for the report.
10. Select the AutoDesign1 node.
11. In the Properties window, set the LayoutTemplate property
to ReportLayoutStyleTemplate and typeAssets for the Title property.
12. In Model Editor, expand the AutoDesign1 node, and then select the node for the DetailsList data
region.
13. In the Properties window, set the style template to ListStyleTemplate and type Asset details for
theTitle property.

44
Reporting in Microsoft Dynamics AX 2012 Labs

To create a parameter that will be used to pass data to the drillthrough report

1. In Model Editor, right-click the Parameters node for the AssetDetails report, point to Add, and
then click Parameter.
2. Select the node for the parameter.
3. In the Properties window, set the Data Type property to String, type SelectedAssetID for
the Nameproperty, and type Asset ID: for the Prompt String property.

To define a filter for the drillthrough report

1. In the AssetDetails design, right-click the node for the DetailsList data region, point to Add, and
then click Filter.
2. Select the node for the filter.
3. In the Properties window, specify =Fields!AssetId.Value for the Expression property,
specify Equals for the Operator property, and specify =Parameters!SelectedAssetID.Value for
the Value property.

Adding a Report Drill Through Action

Now that you have created a top-level report and a drillthrough report, you are ready to add a report drill
through action to link the two reports together. A report drill through action is defined on the top-level
report. The following procedure explains how to add a drill through action.

To add a report drill through action

1. In Solution Explorer, double-click AssetList to open the model in Model Editor.


2. Expand the Designs node for the AssetList report, expand the AutoDesign1 node, expand the
node for the AssetsTable data region, and then expand the Data node.
3. Right-click the Name node, point to Add, and then click Report Drill Through Action.
4. Select the node created for the report drill through action.
5. In the Properties window, click the ellipsis button (…) for the Report Design property. A dialog
box displays.
6. In the dialog box, expand the AssetDetails report, select the AutoDesign1 node for that report,
and then click OK.

Note

After you select a design, the parameters for the drillthrough report display below the
node for the drill through action in Model Editor.

7. In Model Editor, select the node for the SelectedAssetID parameter that is located below the
node for the drill through action.
8. In the Properties window, specify =Fields!AssetId.Value for the Value property.

45
Reporting in Microsoft Dynamics AX 2012 Labs

9. In Model Editor, select the node for the AX_CompanyName parameter that is located below the
node for the drill through action.
10. In the Properties window, specify =Parameters!AX_CompanyName.Value for the Value property.

To preview the drillthrough report

1. In Model Editor, right-click the AutoDesign1 node for the AssetList report, and then
click Preview. TheAssetList report displays.
2. You will see links in the report that indicate the drillthrough was created but you must verify the
link to the report detail in the client. For more information, see How to: Create a Menu Item for a
Report.

46
Reporting in Microsoft Dynamics AX 2012 Labs

Walkthrough10: Creating a Matrix Report


In this walkthrough, you will create a report to display customer transaction data in a matrix data region. A
matrix data region displays data in a two-dimensional grid of columns and rows that intersect at specific
data points. When defining a matrix data region, you can specify column and row groupings. The data
that appears in the detail cells are aggregates based on the intersections of columns and rows.

This walkthrough illustrates the following tasks:

 Defining a query
 Creating a reporting project
 Creating a report with a matrix data region

Prerequisites

To complete this walkthrough, you will need:

 Microsoft Dynamics AX with sample data

Note

This walkthrough uses the CustTable, CustTrans, and CustGroup tables. In order to view
data in the report, these tables must be populated with data.

 Microsoft Visual Studio 2010


 Microsoft Dynamics AX tools for Microsoft Visual Studio

Defining a Query

There are several ways to retrieve data for reports. In this walkthrough, you will use a query that is defined
in the Microsoft Dynamics AX development workspace. The following procedure explains how to define
the query that will be used to retrieve customer transaction data.

To define a query

1. Open Microsoft Dynamics AX.


2. In the AOT, right-click the Queries node, and then click New Query.
3. Right-click the node for the query, click Rename, and then type CustTransactions.

10
Source: http://msdn.microsoft.com/en-us/library/cc623805.aspx

47
Reporting in Microsoft Dynamics AX 2012 Labs

4. Expand the CustTransactions query.


5. Right-click the Data Dictionary node, and then click Open New Window.
6. In the new window, expand the Tables node.
7. Locate the CustTable table and drag it onto the Data Sources node for the query.
8. Expand the node for the CustTable data source.
9. Select the Fields node, in the Properties window, set the Dynamic property to Yes.
10. Locate the CustTrans table and drag it onto the Data Sources node located below
the CustTable data source.
11. Expand the node for the CustTrans data source.
12. Select the Fields node, in the Properties window, set the Dynamic property to Yes.
13. Locate the CustGroup table and drag it onto the Data Sources node located below
the CustTrans data source.
14. Expand the node for the CustGroup data source.
15. Select the Fields node, in the Properties window, set the Dynamic property to Yes.
16. Right-click the Relations node for the CustTrans data source, and then click New Relation.
17. Select the node for the relation and specify the following values in the Properties window.

Property Value
JoinDataSource CustTable_1

Field AccountNum

Related Field AccountNum

18. Expand the node for the CustGroup data source.


19. Right-click the Relations node for the CustGroup data source, and then click New Relation.
20. Select the node for the relation and specify the following values in the Properties window.

Property Value
JoinDataSource CustTable_1

Field CustGroup

Related Field CustGroup

21. Save the query.

Creating a Reporting Project

Next, you will create a reporting project. When you create a Microsoft Dynamics AX project in Microsoft
Visual Studio, you can decide from two project templates: Report Model and EP Web Application. In this
walkthrough, you will use the Report Model template. This will give you access to several predefined

48
Reporting in Microsoft Dynamics AX 2012 Labs

layout and style templates that you will use to define the layout of your reports. These templates are the
standard templates for Microsoft Dynamics AX reports.

To create a reporting project

1. Open Microsoft Visual Studio.


2. On the File menu, point to New and then click Project. The New Project dialog box is displayed.
3. In the Installed Templates pane, click the Microsoft Dynamics AX node. In the Templates pane,
clickReport Model.
4. In the Name box, type SampleMatrixReport, and in the Location box, type a location.
5. Click OK.

Creating a Report with a Matrix Data Region

Next, in the reporting project, you will create a report that displays customer transaction data in a matrix
data region. You will define a column grouping based on the TransDate field and two row groupings
based on theName and AccountNum fields. The following procedure explains how to create the report.

To create a report with a matrix data region

1. In Solution Explorer, right-click the project, point to Add, and then click Report.
2. In Model Editor, right-click the Report1 node and then click Rename.
3. Type SampleMatrixReport as the name.
4. Right-click the Datasets node for the report, and then click Add Dataset.
5. Select the node for the dataset.
6. In the Properties window, specify the following property values.

Property Value
Data Dynamics AX
Source

Data Query
Source
Type

Default Matrix
Layout

Name CustTransactions

Query Click the ellipsis button (…). A dialog box displays where you can select a
query that is defined in the AOT and identify the fields that you want to use.
Select the CustTransactionsquery and then click Next. Expand the All

49
Reporting in Microsoft Dynamics AX 2012 Labs

Fields node for CustTable. Select theAccountNum field from


the CustTable table. Expand the CustTrans > All Fields node, select
the AmountMST and TransDate fields from the CustTrans table. Expand
theCustGroup > All Fields node, select the Name field from
the CustGroup table.

7. In Model Editor, select the Datasets > CustTransactions > Fields > AmountMST node.
8. In the Properties window, set the Aggregate Function property to Sum and set the Format
Stringproperty to Currency.
9. In Model Editor, drag the CustTransactions node onto the Designs node. An auto design
namedAutoDesign1 is created for the report.
10. Expand the AutoDesign1 node, expand the node for the matrix data region, and then expand
the Datanode.
11. Drag the TransDate field from the Data node onto the Column Groupings node.
12. Select the TransDate node.
13. In the Properties window, type the expression =Year(Fields!TransDate.Value) for
the Label property.
14. In Model Editor, expand the TransDate node, expand the Group on node, and then select
theTransDate node that is located below the Group on node.
15. In the Properties window, type the expression =Year(Fields!TransDate.Value) for
the Expressionproperty.
16. In Model Editor, drag the Name field from the Data node onto the Row Groupings node.
17. Select the Name node.
18. In the Properties window, set the Display Width property to 1in and set the Display
Subtotals property to False.
19. In Model Editor, drag the AccountNum field from the Data node onto the Row Groupings node.
20. Select the AccountNum node.
21. In the Properties window, set the Display Width property to 1in and set the Display
Subtotals property to False.
22. In Model Editor, select the AmountMST node that is located below the Data node.
23. In the Properties window, set the Display Width property to 1in, and set the Text
Align property toRight.

To apply layout and style templates

1. In Model Editor, select the AutoDesign1 node.


2. In the Properties window, set the Layout Template property to ReportLayoutStyleTemplate.
Also, type Customer transactions for the Title property.
3. In Model Editor, expand the AutoDesign1 node, and then select the node for the matrix data
region.
4. In the Properties window, set the Style Template property to MatrixStyleTemplate. Also, delete
the default text for the Title property so that it does not display a title for the data region.
5. In Model Editor, right-click the AutoDesign1 node, and then click Preview.
6. Close the Preview window.

50
Reporting in Microsoft Dynamics AX 2012 Labs

Walkthrough11: Creating a Column Chart Report


A chart provides a graphical representation of data. Displaying data in a chart makes it easy for users to
see comparisons, patterns, and trends in the data. In this walkthrough, you will create a report to display
customer transaction data in a column chart.

This walkthrough illustrates the following tasks:

 Defining a query
 Creating a reporting project
 Creating a report with a column chart
 Creating and configuring report parameters and filters
 Applying layout and style templates
 Changing the format to a bar or line chart

Prerequisites

To complete this walkthrough, you will need:

 Microsoft Dynamics AX with sample data

Note

This walkthrough uses the CustTable, CustTrans, and CustGroup tables. In order to view
data in the report, these tables must be populated with data.

 Microsoft SQL Server 2008


 Microsoft Visual Studio 2010
 Microsoft Visual Studio tools for Microsoft Dynamics AX

Defining a Query

There are several ways to retrieve data for reports. In this walkthrough, you will use a query that is defined
within the Microsoft Dynamics AX development environment. You will create a query using
the CustTable table as the data source. In the report, you will filter the data that is displayed based on
the TransType field that is from the CustTrans table so you will add the CustTrans table as a data source.

11
Source: http://msdn.microsoft.com/en-us/library/cc554854.aspx

51
Reporting in Microsoft Dynamics AX 2012 Labs

The following procedure explains how to define the query that will be used to retrieve customer
transaction data.

To define a query

1. Open the Microsoft Dynamics AX Development Workspace.


2. In the AOT, right-click the Queries node, and then click New Query.
3. Right-click the node for the query, click Rename, and then type CustTransactionData. Expand the
node for the CustTransactionData query.
4. Right-click the Data Dictionary node, and then click Open New Window.
5. In the new window, expand the Tables node.
6. Locate the CustTable table and drag it onto the Data Sources node for the query.
7. In the CustTable_1 data source node, select the Fields node, in the Properties window, set
the Dynamicproperty to Yes.
8. Locate the CustTrans table and drag it onto the Data Sources node located below
the CustTable data source.
9. In the CustTrans_1 data source node, select the Fields node, in the Properties window, set
the Dynamicproperty to Yes.
10. Right-click the Relations node for the CustTrans data source, and then click New Relation.
11. Select the node for the relation and verify the following default values in the Properties window.

Property Value
JoinDataSource CustTable_1

Field AccountNum

Related Field AccountNum

12. In the AOT, right-click the Ranges node for the CustTrans data source, and then click New
Range.
13. Select the node for the range, and in the Properties window, select the TransType field from the
drop-down menu for Field.

Note

A report parameter is automatically generated for the range when the query is used in a
report dataset and the Dynamic Filters property is set to False.

14. The TransType field is an enum type. When you define the report, you must know the value of
theEnumType property when you define the AX Enum Provider data source. To find the property
value, in the AOT, click Data Dictionary > Tables > CustTrans > Fields > TransType. In the
Properties window, note that the EnumType property is set to LedgerTransType.

52
Reporting in Microsoft Dynamics AX 2012 Labs

15. Locate the CustGroup table and drag it onto the Data Sources node located below
the CustTrans data source.
16. In the CustGroup_1 data source node, select the Fields node, in the Properties window, set
theDynamic property to Yes.
17. Right-click the Relations node for the CustGroup data source, and then click New Relation.
18. Select the node for the relation and specify the following values in the Properties window.

Property Value
JoinDataSource CustTable_1

Field CustGroup

Related Field CustGroup

19. Save the query.

Creating a Reporting Project

Next, you will create a reporting project in Microsoft Visual Studio. When you create an Microsoft
Dynamics AX project, you can choose from two project templates: Report Model and EP Web
Application. In this walkthrough, you will use the Report Model template.

To create a reporting project

1. Open Microsoft Visual Studio.


2. On the File menu, point to New, and then click Project. The New Project dialog box displays.
3. In the Installed Templates pane, click Microsoft Dynamics AX node, and in
the Templates pane, clickReport Model.
4. In the Name box, type SampleChartReport, and in the Location box, type a location.
5. Click OK.

Creating a Report with a Column Chart

Before you create a chart, you need to decide what type of chart to create. There are two types of
charts: XY charts and pie or doughnut charts. An XY chart is a column, line, or bar chart. During design, you
can switch between related chart types. For example, you can create a column chart and then later change
it to a bar or line chart. In this walkthrough, you will begin by creating a column chart. Later in the
walkthrough, you will change the design so that the data displays in a bar chart and then in a line chart.

53
Reporting in Microsoft Dynamics AX 2012 Labs

To create a report with a column chart

1. In Solution Explorer, right-click the SampleChartReport project, point to Add, and then
click Report.
2. In Model Editor, right-click the Report1 node, and then click Rename.
3. Type ColumnChartReport as the name.
4. Expand the ColumnChartReport node if it is not already expanded.
5. Right-click the Datasets node, and then click Add Dataset.
6. Select the node for the dataset.
7. In the Properties window, specify the following values.

Property Value
Data Dynamics AX
Source

Data Query
Source
Type

Default ColumnChart
Layout

Dynamic False
Filters

Name CustomerTransactions

Query Click the ellipsis button (…). A dialog box displays where you can select a
query that is defined in the AOT and identify the fields that you want to use.
Select theCustTransactionData query. Expand the CustTrans > All
Fields node. Select the TransDateand AmountMST fields. Expand
the CustGroup > All Fields node and select the Namefield.

8. In Model Editor, expand the node for the CustomerTransactions dataset if it is not already
expanded.
9. Select the AmountMST field, and in the Properties window, set the Aggregate
Function property toSum and the Format String property to Currency.
10.
11. Right-click the Datasets node, and then click Add Dataset. You will create an dataset with an AX
Enum Provider data source for the TransType enum field. This will allow you to filter the report to
show specific transaction types.
12. Select the node for the dataset.
13. In the Properties window, specify the following values.

54
Reporting in Microsoft Dynamics AX 2012 Labs

Property Value
Data Source Dynamics AX

Data Source Type AX Enum Provider

Default Layout Table

Dynamic Filters False

Name LedgerTransTypeEnum

Query LedgerTransType

14. Drag the CustomerTransactions node onto the Designs node for the report. An auto design
calledAutoDesign1 is created for the report.
15. Expand the AutoDesign1 node, expand the node for the chart data region, and then expand
the Datanode.
16. Drag the Name field to the Categories node.
17. Drag the TransDate field to the Series node.

Note

The AmountMST field should be the only field that remains below the Data node.

18. Select the node for the TransDate series.


19. In the Properties window, type =Year(Fields!TransDate.Value) for the Label property.
20. In Model Editor, expand the node for the TransDate series, expand the GroupOn node, and then
select the TransDate node that is located below the GroupOn node.
21. In the Properties window, type =Year(Fields!TransDate.Value) for the Expression property.

Creating and Configuring Report Parameters and Filters

Next, you will create and configure several parameters and filters for the report. The report already
contains a parameter for the TransType field since a range based on this field was added to the query
when it was defined in the AOT and you set the Dynamic Filters property for the data set to False. You
will add some additional parameters to allow users to specify the to date and from date. After you have
created the parameters, you will create filters to filter the data based on the range specified by the user.
The following procedure explains how to create and configure the report parameters and filters.

55
Reporting in Microsoft Dynamics AX 2012 Labs

To create and configure report parameters and filters

1. In Model Editor, expand the Parameters node, and then select


the CustomerTransactions_TransTypeparameter.
2. In the Properties window, set the following property values:

Property Value
Allow Blank False

Data Type Integer

Default 2
Value
This will display only the Sales order transactions on the report.

Values Click the ellipsis button (...) to open the Select Values dialog box. Set the
following values:
 Dataset: LedgerTransTypeEnum
 Value field: Value
 Label field: Label

Visibility Hidden

3. This will limit the query to return only sales invoice transactions and hide the parameter so that it
does not display to the users.
4. In Model Editor, right-click the Parameters node and then click Add Parameter.
5. Select the node for the parameter.
6. In the Properties window, specify the following values.

Property Value
Data Type DateTime

Name FromDate

Prompt String From date:

7. In Model Editor, right-click the Parameters node and then click Add Parameter.
8. Select the node for the parameter.
9. In the Properties window, specify the following values.

Property Value

56
Reporting in Microsoft Dynamics AX 2012 Labs

Data Type DateTime

Name ToDate

Prompt String To date:

10. In Model Editor, expand the Designs node, expand the AutoDesign1 node, and then expand the
node for the chart data region.
11. Right-click the Filters node, and then click Add Filter.
12. Select the node for the filter.
13. In the Properties window, specify the following values.

Property Value
Expression =Fields!TransDate.Value

Name FromDateFilter

Operator GreaterThanOrEquals

Value =Parameters!FromDate.Value

14. In Model Editor, right-click the Filters node, and then click Add Filter.
15. Select the node for the filter.
16. In the Properties window, specify the following values.

Property Value
Expression =Fields!TransDate.Value

Name ToDateFilter

Operator LessThanOrEquals

Value =Parameters!ToDate.Value

Applying Layout and Style Templates

Next, you will specify layout and style templates for the report. A layout template defines the general
layout and style settings for a report. A style template contains the layout and style settings for a data
region that displays in the body of a report. You will apply the predefined templates that provided by the
Microsoft Dynamics AX framework. These templates are the standard templates for Microsoft Dynamics
AX reports. The following procedure explains how to apply layout and style templates to the report.

57
Reporting in Microsoft Dynamics AX 2012 Labs

To apply layout and style templates

1. In Model Editor, select the AutoDesign1 node.


2. In the Properties window, set the LayoutTemplate property to ReportLayoutStyleTemplate.
Also, typeCustomer transactions for the Title property.
3. In Model Editor, expand the AutoDesign1 node, and then select the node for the chart data
region.
4. In the Properties window, set the Style Template property to ColumnChartStyleTemplate.
5. Delete the default text for the Title property so that it does not display a title for the data region.
6. Set the Value Axis Data Scale Minimum property to 5. This will set the starting value on the axis
of your report to 5 instead of 0. This is one of many properties that will define the look of your
report.
7. In Model Editor, right-click the AutoDesign1 node, and then click Preview to view the report.
Specify dates for the parameters, and then click the Report tab to view the report.
8. Close the Preview window.

Changing the Format to a Line or Bar Chart

During design, you can switch between several related chart types. First, you will switch from a column
chart to a bar chart. After that, you will switch it to a line chart. The following procedures explain how to
switch between chart types.

To switch the format to a bar chart

1. In Model Editor, select the node for the CustomerTransactionsXYChart chart data region.
2. In the Properties window, set the Chart Type property to Bar.
3. From the Model Editor toolbar, click Preview.

To switch the format to a line chart

1. In Model Editor, select the node for the CustomerTransactionsXYChart chart data region.
2. In the Properties window, set the Chart Type property to Line.
3. Click the tab for the Preview window to view the changes.

58
Reporting in Microsoft Dynamics AX 2012 Labs

Lab 3.112 Create a Report Using Cube Data

This lab explains the process of creating a new analysis cube and using data
from the cube on a Role Center web part.

Note: Before starting this lab, ensure the SQL Server service is running on the
demo server.

Scenario

Isaac, a developer at Contoso, has been asked to add a new graphic to the Sales
Managers role center page. The manager wants to see a bar graph of sales
amounts for each month. The sales amounts will be based on sales order
invoices.

Challenge Yourself

Use the information that was provided in the scenario to create a report to
display on the Sales Manager Role Center.

Need a Little Help?


8. Create a reporting project
9. Define a data source
10. Create a report
11. Add the report to a Role Center web part

Step by Step
12. Open Visual Studio 2010. If this is the first time running Visual
Studio, select General Development Settings for the default
environment settings.
13. In Visual Studio, click File > New > Project. The New Project dialog
box is displayed.
14. In the Installed Templates section, click Microsoft Dynamics AX and
then click Report Model.
15. In the Name box, type SalesReport and in the Location box, type a
location.
16. Click OK.

12
Microsoft Dynamics AX 2012 Reporting, Chapter 3.

59
Reporting in Microsoft Dynamics AX 2012 Labs

17. In Visual Studio Solution Explorer, right-click the SalesReport


project, point to Add, and then click Report Datasource. The model
opens in Model Editor.
18. In Model Editor, select the node for the data source.
19. In the Properties window, specify the following values:
o Name: SalesReportOLAPData
o Provider: OLAP
20. For the Connection String parameter enter the following:
Provider=MSOLAP.4;Integrated Security=SSPI;Persist Security
Info=True;Data Source=[YourServerName];Initial Catalog=Dynamics
AX

Replace [YourServerName] with the name of your server, such as


SEA-DEV.
21. In Visual Studio Solution Explorer, right-click the SalesReport
project, point to Add, and then click Report.
22. Select the Report1 node.
23. In the Properties window, type "SalesChart" as the name.
24. Expand the node for the report if it is not already expanded.
25. Right-click the Datasets node, and then click Add Dataset.
26. Select the node for the dataset.
27. In the Properties window, specify the following values:
o Data Source: SalesReportOLAPData
o Data Source Type: Query
o Default Layout: ColumnChart
o Name: Sales
28. For the Query property, enter the following expression: SELECT
{[Measures].[Customer invoice amount - accounting currency]} ON
COLUMNS,
{[Date].[Year].&[2008-01-01T00:00:00],
[Date].[Year].&[2009-01-01T00:00:00],
[Date].[Year].&[2010-01-01T00:00:00]}
ON ROWS
FROM "Sales cube"
29. Click OK to save the query.
30. In Model Editor, drag the Sales dataset onto the Designs node to
create an auto design.
31. In Model Editor, select AutoDesign1 node.
32. In the Properties window, set the LayoutTemplate property to
ReportLayoutStyleTemplate.
33. In Model Editor, expand the AutoDesign1 node, and then select
SalesXYChart node.

60
Reporting in Microsoft Dynamics AX 2012 Labs

34. In the Properties window, set the Style Template property to


ColumnChartStypleTemplate.
35. Click Deploy SalesReport on the Build menu.
36. Right-click the SalesReport project and then click Add SalesReport
to AOT.
37. Open the development workspace in Microsoft Dynamics AX. If it
was already open, close and re-open it to refresh the metadata.
38. Open the AOT. Expand the Menu Items node, right-click Output,
and then click New Menu Item.
39. On the properties sheet for the new menu item, set the following
values.
o Name: SalesReport
o Label: Sales Chart
o Object Type: SSRSReport
o Object: SalesChart
o ReportDesign: AutoDesign1
40. In Microsoft Dynamics AX, navigate to System Administration >
Common > Users > User Profiles.
41. Select the Sales Manager profile and click View Role Center.
42. On the Site Actions menu, click Edit Page. Locate the Middle
Column section and then click Add a Web Part.
43. Select Microsoft Dynamics AX, click Report, and then click Add.
44. On the Edit menu for the web part, click Edit Web Part. The
properties for the web part are displayed.
45. Click the lower-right area of the Right Column (where the bottom
scroll bar should be) to cause the scroll bars to appear.
46. In the Select a report section, select Sales Chart.
47. Click OK.
48. To view the completed role center page, close the Enterprise Portal
and re-open by clicking View Role Center from the Microsoft
Dynamics AX User Profile window.

61
Reporting in Microsoft Dynamics AX 2012 Labs

Walkthrough13: Creating a Cube


In this walkthrough, you will create a cube that enables you to analyze data from Microsoft Dynamics AX.
You will use the Business Intelligence (BI) properties in Microsoft Dynamics AX to specify measures and
attributes for the cube, and then generate an Analysis Services project so that you can work with the cube
in SQL Server Business Intelligence Development Studio (BIDS).

In this walkthrough you will create an analysis cube called Sales analysis that will allow you to analyze the
following data for the Contoso company:

 Sales revenue by quarter, months, and weeks


 Sales revenue by payment mode
 Average sales by customer group

This walkthrough includes the following tasks:

 Creating a perspective for a cube


 Specifying cube measure and attributes
 Generating an Analysis Services project
 Deploying a cube
 Browsing cube data

Prerequisites

To complete this walkthrough, you will need:

 Microsoft Dynamics AX with sample data


 SQL Server Business Intelligence Development Studio
 Analysis Services extensions for Microsoft Dynamics AX

Creating a Perspective for the Cube

A cube is defined by its measures and dimensions. A measure is quantifiable, like sales, receivables, or
item quantities. Dimensions are used to slice measures. For example, sales by quarter, sales by payment
group, or sales by customer group. You can specify measures and dimensions to model a cube in the
Application Object Tree (AOT). A perspective is a container for the tables and views that contain the
measures and dimensions for a cube. For this walkthrough, you will create a perspective, add Microsoft

13
http://msdn.microsoft.com/en-us/library/cc622026.aspx

62
Reporting in Microsoft Dynamics AX 2012 Labs

Dynamics AX tables and views to the perspective, and then define measures and dimensions by using the
views and table in the perspective.

The following procedures explain how to create a perspective for the cube and how to add views and
tables to the perspective.

To create a perspective for the cube

1. In the AOT, expand the Data Dictionary node. Right-click the Perspectives node, and then
click New Perspective.
2. Select the node of the perspective. In the Properties sheet, specify the following property values:

Property Value
Name SalesAnalysis

Label Sales analysis

Usage OLAP

3. The Usage property determines how the perspective will be used. Setting the Usage property
to OLAP indicates that the perspective will be used to generate an Analysis Services project.

To add views to the perspective

1. In the AOT, right-click the Data Dictionary node, and then click Open New Window.
2. In the new window, expand the Views node. Drag the following views onto the Views node of
the SalesAnalysis perspective:

View Description
CustTransTotalSales Contains sales invoice details.

CustTableCube Contains master customer data.

3. In the AOT, right-click the SalesAnalysis perspective, and then click Save.

To add a table to the perspective

1. In the second AOT, expand the Tables node. Drag the following table onto the Tables node of
the SalesAnalysis perspective:

View Description

63
Reporting in Microsoft Dynamics AX 2012 Labs

CustPaymModeTable Contains payment mode information.

2. In the AOT, right-click the SalesAnalysis perspective, and then click Save.

Specifying Cube Measures and Attributes

You must specify measures and attributes to analyze the desired sales information. To do this, you need
to set properties on each view and table in the SalesAnalysis perspective.

The following procedures explain how to set BI properties on the views and table.

To set properties on the CustTransTotalSales view

1. In the SalesAnalysis perspective, select the CustTransTotalSales view.


2. In the Properties sheet, specify the following values.

Property Value
AnalysisDimensionType Transaction

AnalysisDimensionLabel Sales type

3. In the Properties sheet, set the following values for each field on the CustTransTotalSales view
in the SalesAnalysis perspective.

Field AnalysisUsag Analysis ExchangeRateDateField


e Default
Total
AmountMST Measure Sum TransDate
Note

The AmountMST value is in the accounting


currency of the company. Microsoft
Dynamics AX converts that amount to the
analysis currency using Microsoft Dynamics
AX exchange rates.

TransType Attribute Auto

TransDate Attribute Auto

64
Reporting in Microsoft Dynamics AX 2012 Labs

All other Auto Auto


fields

To set properties on the CustTableCube view

1. In the SalesAnalysis perspective, select the CustTableCube view.


2. In the Properties sheet, specify the following values.

Property Value
AnalysisDimensionType Auto

AnalysisDimensionLabel Customer information

AnalysisMeasureGroupLabel Customer details

3. In the Properties sheet, set the following values for each field on the CustTableCube view in
the SalesAnalysis perspective.

Tip

You can select several fields and set their property


values at the same time.

Field AnalysisUsage AnalysisDefaultTotal


AccountNum Measure Count

Blocked Attribute Auto

GroupName Attribute Auto

City Attribute Auto

County Attribute Auto

Name Attribute Auto

State Attribute Auto

MainContactWorker Attribute Auto

65
Reporting in Microsoft Dynamics AX 2012 Labs

All other fields Auto Auto

To set properties on the CustPaymModeTable table

1. In the SalesAnalysis perspective, select the CustPaymModeTable table.


2. In the Properties sheet, specify the following values.

Property Value
IsLookup No

AnalysisDimensionType Auto

3. In the Properties sheet, set the following values for each field on the CustPaymModeTable view
in the SalesAnalysis perspective.

Field AnalysisUsage AnalysisDefaultTotal


Name Attribute Auto

PaymMode Attribute Auto

TypeOfDraft Attribute Auto

AccountType Attribute Auto

All other Auto Auto


fields

Generating an Analysis Services Project

Now that you have created a perspective and specified the measures and attributes for the cube, generate
an Analysis Services project so that you can work with the analysis cube in BIDS.

The following procedure explains how to generate an Analysis Services project.

To generate an Analysis Services project

1. Click Tools > Business Intelligence (BI) tools > SQL Server Analysis Services project wizard.
The SQL Server Analysis Services project wizard form appears.
2. Click Next.
3. Select Create. In the Project name field, type Dynamics AX SalesAnalysis. Click Next.
4. Select Sales analysis from the Available list and move it to the Selected list and then click Next.

66
Reporting in Microsoft Dynamics AX 2012 Labs

5. On the Select Microsoft Dynamics AX dimensions page, click Next.


6. Select Date from the Available list and move it to the Selected list and then click Next.
7. Select Arabic, Chinese (Simplified), and English (United States) from the Available list and
move them to the Selected list and then click Next.
8. Select Add foreign currency support to the Analysis Services project and then click Next.
After the project is generated, clickNext again.
9. Select Save to AOT. Select [New] from the list to create a new AOT node. Select Save to disk,
type the location to which to save the project, and then click Next.
10. On the Deployment options page, Select Deploy the project. Specify the server name. For
example, localhost. Select Create new database. Type Dynamics AX SalesAnalysis. Select Process
the project after it is successfully deployed and then click Next. ClickNext and then
click Finish.

Browsing Cube Data

Now that the SalesAnalysis cube has been deployed and processed, you can browse the cube data within
the Analysis Services project. The following procedure explains how to browse the cube data.

To browse the analysis cube data

1. In BIDS, open the Dynamics AX SalesAnalysis Analysis Services project. You can open it from the
location you saved it to on your hard drive, or you can open it from the AOT. To open the project
from the AOT, right-click Visual Studio Projects > Analysis Services Projects > Dynamics AX
SalesAnalysis and then click Edit.
2. In Solution Explorer, double-click SalesAnalysis.cube.
3. Click the Browser tab.
4. Expand the Measures node, expand the Total customer sales node, right-click Amount, and
then click Add to Data Area.
5. Expand the Customers node, right-click State, and then click Add to Row Area.
6. Expand the Customers node, right-click Customers - Name, and then click Add to Row Area.
7. Browse the data. You can expand and collapse rows and columns in the table. You can modify the
rows and columns that display in the table or add other dimensions to further slice the data.

To view cube objects in the generated project

1. Expand the Data Sources node. A data source that connects to the Microsoft Dynamics AX OLTP
database is displayed.

A data source is used to source and refresh cube data.

2. Expand the Data Source Views node, and then double-click Dynamics AX SalesAnalysis.

A data source view provides a unified view of the tables and their relationships.

67
Reporting in Microsoft Dynamics AX 2012 Labs

3. In Solution Explorer, expand the Cubes node, and then double-click SalesAnalysis.cube to
display Cube Designer.

Cube Designer allows you to view and edit various properties of a cube. There are several tabs
that display different views of the cube. For example, click the Dimension Usage tab to display
the mappings between dimensions and measure groups.

Note

Notice that the relationships between the measures and dimensions have been
inferred by using the relationships in Microsoft Dynamics AX.

Click the Translations tab to view the translations that exist for the cube. The SalesAnalysis cube
has three translations, Arabic (Saudi Arabia) English (United States) and Chinese (People’s
Republic of China).

4. In Solution Explorer, expand the Dimensions node to view the dimensions for the cube.

68
Reporting in Microsoft Dynamics AX 2012 Labs

Lab 4.1 14Create a Report to Display in a Role Center

This lab examines many of the concepts that were introduced in previous
chapters of this course. In this lab you will create a new SSRS report and a new
role center. Then you will bring them together in the Microsoft Dynamics AX
2012 client. For clarity, this lab will be broken up into separate exercises.

Scenario

You work in the IT department of a large manufacturing company, providing


support for the Microsoft Dynamics AX 2012 installation that is used by almost
all departments.

The company's CEO has just hired a new employee and has appointed the newly
created position of Chief Accounting Officer (CAO). The new employee will
oversee the Accounting department and all the Accounting Managers.

The CEO has requested that the IT department provide the new CAO with access
to Microsoft Dynamics AX 2012. And because this is a new position, you are to
create a new role center that is designed around the position.

The new role center should look much like the Accounting Manager role center,
with a few new additions. It should include a new report, showing the amount
of open transactions with time parameter, as a column chart.

Challenge Yourself

Use the information that was provided in the scenario to meet the
requirements.

Step by Step - Define a Query

Follow these steps to create a new query:

49. Open Microsoft Dynamics AX 2012 by clicking the shortcut on the


desktop. Press Ctrl+Shift+W to open the Microsoft Dynamics
development workspace.
50. In the AOT, right-click the Queries node, and then click New Query.

14
Microsoft Dynamics AX 2012 Reporting, Chapter 4.

69
Reporting in Microsoft Dynamics AX 2012 Labs

51. Right-click the node for the query, click Rename, and then type
CustTransactionData. Expand the node for the CustTransactionData
query.
52. Right-click the Data Dictionary node, and then click Open New
Window.
53. In the new window, expand the Tables node.
54. Locate the CustTable table and drag it onto the Data Sources node
under the CustTransactionData query.
55. Expand the CustTable_1 data source node, select the Fields node,
and in the Properties window, set the Dynamic property to Yes.
56. Locate the CustTrans table and drag it onto the Data Sources node
located below the CustTable data source (not the higher level Data
Source node under the CustTransactionData query).
57. In the CustTrans_1 data source node, select the Fields node, in the
Properties window, set the Dynamic property to Yes.
58. Right-click the Relations node for the CustTrans_1 data source, and
then click New Relation.
59. Select the node for the relation and verify the following default
values in the Properties window
o JoinDataSource: CustTable_1
o Field: AccountNum
o Related Field: AccountNum
60. In the AOT, right-click the Ranges node for the CustTrans_1 data
source, and then click New Range.
61. Select the node for the range, and in the Properties window, select
the TransType field from the drop-down menu for Field.
62. The TransType field is an enum type. When you define the report,
you must know the value of the EnumType property when you
define the AX Enum Provider data source. To find the property
value, in the AOT, click Data Dictionary > Tables > CustTrans >
Fields > TransType. In the Properties window, note that the
EnumType property is set to LedgerTransType.
63. Locate the CustGroup table and drag it onto the Data Sources node
located below the CustTrable_1 data source (not the higher level
Data Source node under the CustTransactionData query and not
the lower level Data Source node under CustTrans_1).
64. Expand the CustGroup_1 data source node, select the Fields node,
and in the Properties window, set the Dynamic property to Yes.
65. Right-click the Relations node for the CustGroup_1 data source, and
then click New Relation.
66. Select the node for the relation and set the following values in the
Properties window
o JoinDataSource: CustTable_1

70
Reporting in Microsoft Dynamics AX 2012 Labs

o Field: CustGroup
o Related Field: CustGroup
67. Save the query.

Step by Step - Create a Reporting Project

Follow these steps to create a Reporting Project in Visual Studio:

68. Open Microsoft Visual Studio.


69. If Visual Studio is run for the first time, select General Development
Settings for the default environment setting and click Start Visual
Studio.
70. On the File menu, point to New, and then click Project. The New
Project dialog box displays.
71. In the Installed Templates pane, click Microsoft Dynamics AX node,
and in the Templates pane, click Report Model.
72. In the Name box, type SampleChartReport, and in the Location box,
type a location.
73. Click OK.

Step by Step - Create a Report

Follow these steps to create a new report:

74. In Solution Explorer, right-click the SampleChartReport project,


point to Add, and then click Report.
75. In Model Editor, right-click the Report1 node, and then click
Rename.
76. Type ColumnChartReport as the name.
77. Expand the ColumnChartReport node if it is not already expanded.
78. Right-click the Datasets node, and then click Add Dataset.
79. Select the node for the dataset.
80. In the Properties window, specify the following values.
o Data Source: Dynamics AX
o Data Source Type: Query
o Default Layout: ColumnChart
o Dynamic Filters: False
o Name: CustomerTransactions
81. For the Query field, click the ellipsis button (…). A dialog box
displays where you can select a query that is defined in the AOT and
identify the fields that you want to use. Select the
CustTransactionData query. Click Next and then expand the
CustTrans_1 > All Fields node. Select the TransDate and

71
Reporting in Microsoft Dynamics AX 2012 Labs

AmountMST fields. Expand the CustGroup > All Fields node and
select the Name field. Click OK.
82. In Model Editor, expand the node for the CustomerTransactions
dataset and expand the Fields node.
83. Select the AmountMST field, and in the Properties window, set the
Aggregate Function property to Sum and the Format String
property to Currency.
84. Right-click the Datasets node, and then click Add Dataset. You will
create a dataset with an AX Enum Provider data source for the
TransType enum field. This will allow you to filter the report to show
specific transaction types.
85. Select the node for the dataset.
86. In the Properties window, specify the following values.
o Data Source: Dynamics AX
o Data Source Type: AX Enum Provider
o Default Layout: Table
o Dynamic Filters: False
o Name: LedgerTransTypeEnum
o Query: LedgerTransType
87. Drag the CustomerTransactions node onto the Designs node for the
report. An auto design called AutoDesign1 is created for the report.
88. Expand the AutoDesign1 node, expand the node for the chart data
region, and then expand the Data node.
89. Drag the Name field to the Categories node.
90. Drag the TransDate field to the Series node.
91. Select the node for the TransDate series.
92. In the Properties window, type =Year(Fields!TransDate.Value) for
the Label property.

Step by Step - Configure Report Parameters

Follow these steps to configure the report parameters:

93. In Model Editor, expand the node for the TransDate series, expand
the GroupOn node, and then select the TransDate node that is
located below the GroupOn node.
94. In the Properties window, type =Year(Fields!TransDate.Value) for
the Expression property.
95. In Model Editor, expand the Parameters node, and then select the
CustomerTransactions_TransType parameter.
96. In the Properties window, set the following property values:
o Allow Blank: False

72
Reporting in Microsoft Dynamics AX 2012 Labs

o Data Type: Integer


o Default Value: 2
o Visibility: Hidden
97. For the Values field, click the ellipsis button (...) to open the Select
Values dialog box. Click From dataset and then set the following
values:
o Dataset: LedgerTransTypeEnum
o Value field: Value
o Label field: Label

98. Click OK to close the Select Values dialog box.


99. In Model Editor, right-click the Parameters node and then click Add
> Parameter.
100. Select the node for the parameter.
101. In the Properties window, specify the following values.
o Data Type: DateTime
o Name: FromDate
o Prompt String: From date:
102. In Model Editor, right-click the Parameters node and then click
Add Parameter.
103. Select the node for the parameter.
104. In the Properties window, specify the following values.
o Data Type: DateTime
o Name: ToDate
o Prompt String: To date:
105. In Model Editor, expand the Designs node, expand the
AutoDesign1 node, and then expand the node for the chart data
region.
106. Right-click the Filters node, and then click Add Filter.
107. Select the node for the filter.
108. In the Properties window, specify the following values.
o Expression: =Fields!TransDate.Value
o Name: FromDateFilter
o Operator: GreaterThanOrEquals
o Value: =Parameters!FromDate.Value

Step by Step - Apply Layout and Style Templates

Follow these steps to apply layout and style templates to the report:

109. In Model Editor, right-click the Filters node, and then click Add
Filter.

73
Reporting in Microsoft Dynamics AX 2012 Labs

110. Select the node for the filter.


111. In the Properties window, specify the following values.
o Expression: =Fields!TransDate.Value
o Name: ToDateFilter
o Operator: LessThanOrEquals
o Value: =Parameters!ToDate.Value
112. In Model Editor, select the AutoDesign1 node.
113. In the Properties window, set the LayoutTemplate property to
ReportLayoutStyleTemplate. Also, type Customer transactions for
the Title property.
114. In Model Editor, expand the AutoDesign1 node, and then select
the node for the chart data region.
115. In the Properties window, set the Style Template property to
ColumnChartStyleTemplate.
116. Delete the default text for the Title property so that it does not
display a title for the data region.
117. Set the Value Axis Data Scale Minimum property to 5. This will
set the starting value on the axis of your report to 5 instead of 0.
This is one of many properties that will define the look of your
report.
118. Click the Save All icon on the menu toolbar to save the report.
119. In Solution Explorer, right-click the SampleChartReport project
and click Build.
120. In Solution Explorer, right-click the SampleChartReport project
and click Deploy.
121. In Solution Explorer, right-click the SampleChartReport project
and click Add SampleChartReport to AOT.

Step by Step - Create Menu Item

Follow these steps to create a menu item in Microsoft Dynamics AX 2012 for the
new report:

122. In the Microsoft Dynamics AX 2012 development environment,


open the AOT.
123. Right-click Output under Menu Items and select New Menu
Item.
124. In the properties window set the following properties:
o Name: CustomerOpenTransactions
o ObjectType: SSRS Report
o Object: ColumnChartReport
o ReportDesign: AutoDesign1

74
Reporting in Microsoft Dynamics AX 2012 Labs

125. Save the Menu Item.

Step by Step - Create Role Center

Follow these steps to create the new Role Center:

126. In Microsoft Dynamics AX, navigate to System Administration >


Setup > Enterprise Portal > Website. Click the Enterprise Portal
record and click View in browser. The Enterprise Portal will open in
a browser.
127. On the Site Actions menu, click More Options. A dialog box that
contains a list of the items that you can create is displayed.
128. Click Page and All Categories under Filter by:.
129. Click Web Part Page, and then click Create.
130. Name the new page EPCAORoleCenter.
131. Choose Header, Footer, 3 Columns as the Layout Template.
132. Select Enterprise Portal for the Document library.
133. Click Create to create the new page. The new webpage will
load. Click No to disable Autocomplete.
134. Create a URL object in Microsoft Dynamics AX 2012 to reference
this new web page. In the Microsoft Dynamics AX 2012 AOT,
navigate to Web > Web Menu Items > URLs. Right-click the URLs
node and select New URL.
135. Open the Properties window for the new URL and set its Name
to EPCAORoleCenter.
136. In the HelpText type CAO Role Center.
137. In the URL type Enterprise%20Portal/EPCAORoleCenter.aspx.
138. Set ConfigurationKey to LedgerBasic.
139. Set HomePage to Yes.
140. Save the URL.
141. Make a new user profile to relate to this Role Center. Navigate
to System Administration > Common > Users > User profiles.
Create a new record.
142. Set Profile ID to CAO.
143. Set Description to Chief Accounting Officer.
144. Set Role Center to EPCAORoleCenter.
145. Assign users to this profile with the Add User button. For the
purposes of this lab, assign your own user. Click on File > Tools >
Options to see your current user ID.

75
Reporting in Microsoft Dynamics AX 2012 Labs

Step by Step - Add Report to Role Center

Because the new role center is going to be fundamentally similar to the


Accounting Manager role center, this procedure will skip the steps that are
involved in adding the same web parts to the new role center that are on the
existing webpage. Once that has been completed, the last step is to add the new
component to the CAO role center.

146. In Microsoft Dynamics AX, navigate to System Administration >


Common > Users > User Profiles.
147. Select the CAO profile and click View role center.
148. Click the Site Actions button, and choose Edit Page. The
webpage will load in Edit mode.
149. Navigate to the Middle Column section.
150. Click on the Add a Web Part button.
151. The Add Web Parts to Middle Column dialog will open. Select
the Microsoft Dynamics AX category, Report web part and click
Add.
152. The new Microsoft Dynamics AX web part displays in the Middle
Column, in its default view. Select the check box in the web part,
click the drop-down arrow and select Edit Web Part. The page will
reload with the Properties window on the right.
153. In the Properties window, select the report using the Output
menu item name, CustomerOpenTransactions.
154. Enter parameters for the From and To dates.
155. Click OK. The role center should reload with the report
displayed.

76
Reporting in Microsoft Dynamics AX 2012 Labs

How to: Create a Cue15


A cue is a type of part that represents a query. You use a cue to show a count of data records that the
query retrieves. Cues appear in cue groups in the FactBox pane and on a role center page. Before you
create a cue, you must complete the following tasks:

1. To get the record count that appears in the cue group or role center, you should identify an
existing query or create a new query that retrieves the specified records. For information about
how to create a query, see How to: Create Queries by Using the AOT.
2. If you want to click the cue and open a form to display the records accessed by the cue, you must
identify a form that shows the type of data records the query retrieves. Typically, you select a form
with a form data source that uses the query from the previous step. For information about how to
create a form, see Forms in Microsoft Dynamics AX.

The following steps show how to create a menu item for a cue.

To Create the Menu Item

1. In the AOT, expand Menu Items, right-click Display, and then click New Menu Item.
2. Click the new menu item. In the property sheet, click Name and specify a name that uniquely
identifies the menu item.
3. Click Label and select the label for the menu item. The menu item label appears in the FactBox
when the Label property of the cue is empty.
4. Click Query and then click the name of the query that you want to use to retrieve the data
records.
5. Click ObjectType and select Form.
6. Click Object and then click the name of the form that you use to show the records from the
query. If you do not want to open a form from the cue, you can leave the property empty.
7. If the cue appears in Enterprise Portal, click WebMenuItemName and select a WebMenuItem.
Use a WebMenuItem that opens a list page that can display the set of records that the cue
retrieved.
8. Right-click the menu item and then click Save.

To Create the Cue

1. In the AOT, expand Parts, right-click Cues, and then click New Cue. A cue is added to the list
of Cues in the AOT.
2. Click the new cue. In the property sheet, click Name and specify a name that uniquely identifies
the cue.
3. Click Label and select the label you want to appear in a FactBox. This step is optional. If the label
is not specified, the cue uses the label from the menu item.

15
http://msdn.microsoft.com/en-us/library/gg841851.aspx

77
Reporting in Microsoft Dynamics AX 2012 Labs

4. Click MenuItemName and select the menu item that you created for the cue. This menu item
specifies the query you want to use, as well as the form (for the Microsoft Dynamics AX client) or
list page (for EP) that will be opened when the cue is clicked.
5. Right-click the cue and then click Save.

78

Vous aimerez peut-être aussi