Example 4: Number of Workers Report
Objective
In this example we want to prepare a report where we will summarize number of workers by departments. We want to display number of all workers and number of full-time workers in two separate columns.
Final result
The generated document will look like in the figure below:
Step by step instructions
This document will be fairly simple to create, given the experience form the previous three examples. It doesn’t involve any new Docentric AX feature, we will just use what we have learnt in our previous examples.
We will get started by creating a new document and make it a Docentric AX template by clicking the “Use As Template” button on the DOCENTRIC AX ribbon tab and choosing the Data Source Package file (.ddsp).
Step 1: Report title
Report title will be displayed by the Field tagging element bound to Main Data => @ReportCaption and formatted as desired.
Step 2: Report parameters
Report parameters will display values in tagging elements, bound to data fields as shown in the table below:
Label | Tagging Element | Binding Source | Binding Path |
---|---|---|---|
Company | Field | General Data | CompanyInfo/@Name |
From | Field | Parameters | @AsOfDate |
Include contractors | If | Parameters | @IncludeContractors |
If (inverted) | Parameters | @IncludeContractors |
The Field tagging element for the “From” parameter uses format string “d” which specifies short date format.
The two mutually exclusive If tagging elements are used to display checked or unchecked checkbox, depending on the data field value, just like in previous reports.
Step 3: Lines with departments and their numbers of workers
Repeating lines will be displayed in a table. This table will have a header row with column names and one row acting as a template for a single line of data (one record).
First we need a table with 4 columns and 2 rows. We can format it as desired and then enter column headers as in the figure below:
We need to select the second table row and click on the List button on the DOCENTRIC AX menu tab. The table row is now marked to serve as a line repeating block template.
With the List tag inserted, we have to bind it to the data records. Our list will be bound to Main Data => HcmNumberOfWorkersTmp. The Data collection will be sorted by Name.
Each table cell in the second row will display one data field from the current record. So we will insert Field tagging elements with the following binding and data formatting properties:
Colum | Binding Source | Binding Path | Format String |
---|---|---|---|
Department Name | Current Data Context | @ DepartmentName | |
Department Number | Current Data Context | @DepartmentNumber | |
Number of workers | Current Data Context | @NumberOfWorkers | n0 |
Full-time workers | Current Data Context | @FullTimeWorkers | n0 |
Format string “n0” displays numbers with thousand separators and without decimals. You can get more information about standard numeric format strings here: https://msdn.microsoft.com/en-us/library/dwhawy9k(v=vs.100).aspx.
The report template is now finished and it should look like in the picture below:
You can now preview the report, to see that it displays values as expected.