Example 2: HCM Birthday Report with Grouping


This report lists employees that have birthday between the specified periods. The first part of the report contains a list of employees grouped by birthday date, while the second part of the report renders a birthday card for each employee.

Final result

The two figures below show how the final document will look like.

Step by step instructions

This demo is similar to the example #1, so we will not go into details with features that were presented there.

Step 1: Basic template layout design

  • Start MS Word 2007 or higher and open a blank document.
  • Add report title and parameters, just like in the example #1.
  • Add a paragraph under the parameters table with the following text:
    “This document contains list of Happy Birthday cards for all workers with the birthday in selected period grouped by the date.”
  • Include watermark text “CONFIDENTIAL” (DESIGN -> Watermark).

The document should now look like this:

Step 2: Grouping employees by birthday dates

Our data source contains employees with birthdays within the specified period. At this point in the document we want to create a list of these employees, grouped by their birthday dates. To display the employees in groups we can use the Group tagging element:

  1. Insert a new Group tag
  2. Bind it to MainData => HcmBirthdayTmp collection.
    • Set the Group By to @BirthdayDate data field. This way we specified that the employee records will be grouped by using the @BirthdayDate data field as the group key.
    • We can also set-up sorting so that the groups will be sorted by the birthday date.
  3. The Group tag still has no display content at this time.

Step 3: Adding content to the Group tag

The Group tagging element groups the collection of employee records by the selected key data field (@BirthdayDate). The content of the Group element will be repeated for each group of records with the same key.

For each group we want to render the birthday date which is the current group key value. To do so, we will position the cursor into the Group tag and press Enter key to enter an empty line. Then enter the text “Data: “ and insert a Field tag and bind it to Current Data Context => @docentricdg:Key.

The Group tag’s Current Data Context is a Group record that contains the Key and the Employee records of a single group. Because the “Group By” data field is of type date-time, we can set its display format in the Field Properties – in our case we will display the name of the month and the number of the day (MMMM d).

If you run the preview, the generated document should look like this:

Step 4: Displaying the group employee list

Next we want to display the list of employees for each group. To achieve this we add a new List tagging element in the new line after the group key Field tag and bind it to Current Data Context => HcmBirthdayTmp data collection.

Optionally, we can also set the sorting, so that the employees in each group will be sorted by Name.

Step 5: Adding Field tags into the List tag

For each employee we want to write out three data fields. We will add three Field tags and bind them to @Name, @Worker and @Age data elements.

Because Age element shows employee’s current age, we want to increment it for 1 year, to show the new age at birthday. We do this by writing an XPath expression, as the following two figures demonstrate:

  1. Field tag has been inserted where we want to calculate new age.
  2. Value button in Field Properties opens a Binding Control.
  3. Instead of selecting a data field, we open the XPath Editor by clicking the pencil button.

The XPath Editor opens, where we enter our expression. In our case, we have expanded Number functions section and chosen the “number” function with the Age element as a parameter. It converts the value of Age element to number and then increases it by 1.

If we preview the report now, we get the results as in the figure below. We see that the data is there, grouped and sorted as expected.

Step 6: Formatting group and list data

We want the employees in each group to be listed in the form of numbered paragraphs. To achieve that we will have to define a new multilevel list in Word. We will apply level 1 to our groups and level 2 to their lists of data. These are all MS Word features, so only basics are described below:
1. We will define a new multilevel list:

2. Next we set properties for levels 1 and 2 as follows:

3. Now we apply new multilevel list to the paragraph with group tag:

1. First we must select the line with the Group tag.
2. Next we click Multilevel List button on HOME tab on the ribbon.
3. Then we select the multilevel list, which we have just defined. Paragraph with the group information now inherits settings of level 1 of the multilevel list.
4. We will now apply multilevel list to the List tag’s paragraph: first we select the paragraph which the List tag wraps and then apply multilevel list as shown on the figure below:

5. Multilevel list is now applied, but not the right level; we will change it so that level 2 is applied (remember that level 1 is the »group« level and level 2 is the employee level):

6. Now we have to instruct Word to continue numbering in this list level from the previous one (this way we join this paragraph numbering with the parent level paragraph numbering):

1. We must select the number at the beginning of the line where the list tag is.
2. Then right-click to get the pop-up menu as shown and select Continue Numbering from the pop-up menu.

Step 7: Creating letter template for birthday cards

Birthday cards will contain birthday greeting cards, based on a template. They will be printed in landscape page orientation, one greeting card per page.
1. We will first start by inserting a new page section break (PAGE LAYOUT ->Breaks -> Next Page).
2. Set landscape orientation in the new section (PAGE LAYOUT -> Orientation -> Landscape).

3. Remove page footer from Section 2:
a. INSERT -> Footer ->Edit Footer.
b. Click on Link to Previous button in the ribbon to remove footer link to section 1.
c. Delete page number field in the footer of Section 2).

4. Remove CONFIDENTIAL watermark from Section 2:
a. INSERT -> Header ->Edit Header.
b. Click Link to Previous button in the ribbon to remove header link to section 1.
c. Delete watermark text in Section 2).

5. Add List tag and bind it to Main Data => HcmBirthdayTmp data collection; sort it by birthday date and name.
6. Align the text to be centered on the page and insert static text in the list tag and an image, as in the figure below.
7. Add Field tags as shown in the figure and bind them to corresponding data.
8. Insert a rectangle, to draw the border around the content; set its properties so that it will not be filled and that the border lines will be light blue and 4pt thick.

Final layout should be like in the figure below:

We’re done! Preview the report to make sure it looks as expected.


Data source (DDSP file) Template