Académique Documents
Professionnel Documents
Culture Documents
Step by Step: Define a Method to Return the Data to Reporting Services .... 16
1
Reporting in Microsoft Dynamics AX 2012 Labs
To add parameters that determine whether to display phone and fax numbers27
2
Reporting in Microsoft Dynamics AX 2012 Labs
To create a parameter that will be used to pass data to the drillthrough report45
3
Reporting in Microsoft Dynamics AX 2012 Labs
4
Reporting in Microsoft Dynamics AX 2012 Labs
5
Reporting in Microsoft Dynamics AX 2012 Labs
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
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
7
Reporting in Microsoft Dynamics AX 2012 Labs
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.
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:
Note
This walkthrough uses the InventTable table. In order to view data in the report, this table
must be populated with data.
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
9
Reporting in Microsoft Dynamics AX 2012 Labs
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.
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.
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.
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.
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.
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
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.
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.
[DataContractAttribute]
public class SrsRDPContractSample
{
AccountNum accountNum;
CustAccountStatement accountStmt;
Boolean inclTax;
}
5. Save the class and close the editor.
[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.
15
Reporting in Microsoft Dynamics AX 2012 Labs
[SRSReportDataSetAttribute("TmpCust")]
public TmpCustTableSample getTmpCustTable()
{
select * from tmpCust;
return tmpCust;
}
3. Save the method and close the editor.
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; }
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
Prerequisites
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.
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.
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.
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.
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.
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.
20
Reporting in Microsoft Dynamics AX 2012 Labs
Property Description
Name SortMainAccountID
Sort By =Fields!MainAccount_MainAccountId.Value
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
Name IncludeAccountName
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.
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.
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.
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.
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.
Next, you will verify that the customized report now displays in Microsoft Dynamics AX.
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
Defining a query
Creating a reporting project
Creating a report
Adding parameters to a report
Prerequisites
Note
This walkthrough uses the CustTable table. In order to view data in the report, this table
must be populated with data.
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
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.
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.
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.
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.
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
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
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
Note
The data that displays in your report may vary depending on the sample data that is available to
you.
Defining queries
Creating a reporting project
Creating a precision design report using SQL Report Designer
Prerequisites
7
Source: http://msdn.microsoft.com/en-us/library/cc624720.aspx
29
Reporting in Microsoft Dynamics AX 2012 Labs
Note
In this walkthrough, you will use the VendInvoiceJour and VendInvoiceTrans tables.
Therefore, these tables must be populated with data.
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.
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.
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.
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
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.
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.
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.
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.
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.
34
Reporting in Microsoft Dynamics AX 2012 Labs
You have successfully formatted your report. In the next section, you will add totals to the report.
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
Prerequisites
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.
8
Source: http://msdn.microsoft.com/en-us/library/cc551711.aspx
37
Reporting in Microsoft Dynamics AX 2012 Labs
SQL
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.
38
Reporting in Microsoft Dynamics AX 2012 Labs
5. Click OK.
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.
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.
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
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
Defining a query
Creating a reporting project
Creating a top-level report and a drillthrough report
Adding a report drill through action
Prerequisites
Note
This walkthrough uses the AssetTable table. In order to view data in the reports, this table
must be populated with data.
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
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.
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.
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.
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.
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.
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.
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.
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.
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
Defining a query
Creating a reporting project
Creating a report with a matrix data region
Prerequisites
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.
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
10
Source: http://msdn.microsoft.com/en-us/library/cc623805.aspx
47
Reporting in Microsoft Dynamics AX 2012 Labs
Property Value
JoinDataSource CustTable_1
Field AccountNum
Property Value
JoinDataSource CustTable_1
Field CustGroup
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.
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.
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
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.
50
Reporting in Microsoft Dynamics AX 2012 Labs
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
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.
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
Property Value
JoinDataSource CustTable_1
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
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.
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
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
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.
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
Property Value
Allow Blank False
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
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
Name ToDate
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
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
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.
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.
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
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.
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
60
Reporting in Microsoft Dynamics AX 2012 Labs
61
Reporting in Microsoft Dynamics AX 2012 Labs
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:
Prerequisites
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.
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
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.
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.
3. In the AOT, right-click the SalesAnalysis perspective, and then click Save.
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
2. In the AOT, right-click the SalesAnalysis perspective, and then click Save.
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.
Property Value
AnalysisDimensionType Transaction
3. In the Properties sheet, set the following values for each field on the CustTransTotalSales view
in the SalesAnalysis perspective.
64
Reporting in Microsoft Dynamics AX 2012 Labs
Property Value
AnalysisDimensionType Auto
3. In the Properties sheet, set the following values for each field on the CustTableCube view in
the SalesAnalysis perspective.
Tip
65
Reporting in Microsoft Dynamics AX 2012 Labs
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.
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.
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
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.
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.
1. Expand the Data Sources node. A data source that connects to the Microsoft Dynamics AX OLTP
database is displayed.
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
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
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.
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.
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.
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
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
Follow these steps to create a menu item in Microsoft Dynamics AX 2012 for the
new report:
74
Reporting in Microsoft Dynamics AX 2012 Labs
75
Reporting in Microsoft Dynamics AX 2012 Labs
76
Reporting in Microsoft Dynamics AX 2012 Labs
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.
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.
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