October 21, 2019
How to use a Layout Component Reference, and override components when necessary!
One of the main struggles report authors face is the maintenance of production reports. It’s not enough to just create the report, one must also ensure the report is updated as changes are made to corporate privacy notifications, colors and logos. This is especially true for companies going through a re-branding process.
Recently QueBIT worked with a client who’s been a Cognos user for many years. They had over 70 reports in production. Each report contained individual items such as headers, footers and images. Some were created so long ago, the colors and images on the report were no longer valid. Any attempt to update branding represented a great deal of repetitive formatting changes.
Our task was to implement a reporting strategy which would minimize this chore. Specifically, we recreated the reports using a shared standard style sheet, enabling the report authors to make style changes to only one source, and have those changes cascade to the other 70 reports automatically. Of course, each report had its specialized formatting needs. For example, when a report was burst on a query item, the item needed to be part of the header. We therefore, needed to ensure we could also override components when necessary. This is where the use of Layout Component References came into play. In the sample below, I’ll walk you through the creation of the standard layout report, how to reference its components, as well as override when necessary.
The City of Boston currently utilizes a “311 System”, which enables city residents or city workers to easily report non-emergency issues. Items such as broken streetlights or graffiti can be reported to the proper city services department via mobile phone applications, online, social media or a phone call.
To accelerate the use of this system, the city has implemented a new logo and branding campaign. Below is a sample of one of the reports. The goal of the task is to ensure all 311 System reports reference a single source for layout components so reports can be updated with minimal effort.
- QueBIT recommends before starting this task, if not already done, create a “Templates” folder and “Style Reference Reports” folder under the “Team content” folder as shown below on the Cognos Portal. These folders will hold the style reference reports used for layout reference components. (The use of templates will be discussed in a later knowledge base article)
- To begin, create the style reference report which will include common reference objects needed for all reports (i.e. header, footer, and logo). When complete, place the report in the “Style Reference Report” folder shown above. For this example, I named the report “Boston City Standard Style”. Rather than going through this process and display activities not included in this article, I’ve identified necessary steps below to ensure the objects within this report can be used for our layout component reference.
- Ensure your objects are encapsulated by blocks, and these blocks have clear and reusable names. For this example, I’ve created a header and footer object, and named them “headercomponent” and “footercomponent” respectively.
- In the headercomponent block, I’ve placed all the items I want to include when I reference it in my data reports. (i.e. logo, report name, page number and page count).
- In the footercomponent block, I’ve included additional privacy text, as well as a function to show the report run date.
- Since no report is completely the same, I’ve also created a text item and named it “subtitle1”. This is the component that will be overridden when additional information is needed in the header. Just as above, you must name the component so it can be referenced.
- Now let’s create the data report, which includes the query of the information we want to report on. For this example, I’ve created a very simple list report, with a section and page break created for each neighborhood. I’ve named it “311 Calls / Service Request Detail”.
- To incorporate the header component created on the standard style report, click the Toolbox icon and drag/drop the layout component reference object above the list object on this report.
- In the component reference box, enter the name of the reference report (Boston City Standard Style) and specific component (headercomponent). Please note, you can also reference another object within the same report. This comes in handy when, for example, there are multiple pages using the same header within the report.
Important. When looking at the properties box for the component reference layout, you have the option to either embed the object as a reference or copy. As the names suggest, a reference stores a pointer to the object and a copy stores a stand-alone copy of the object. In this case, use reference, as you want the data report to automatically update when changes are made on the style reference report.
- Repeat step #5, but this time choose the “footercomponent”. This is what your design should look like. Please note, header and footer layout component references are highlighted in blue.
- Run the report. Your layout component reference should be working well. However, notice subtitle1 is still showing. Let’s take care of this in the next step.
- For this report, I want to add the neighborhood query item as part of the header. Click on the “headercomponent” layout component reference and turn properties box on. Under override, choose item subtitle1 and click OK.
You will see the subtitle item has changed …
Now drag and drop the neighborhood query item to this spot.
- Rerun the report, and you will now see the report as shown above.