Recently I was contacted by a fellow blogger, who had been scratching his head because of disappearing labels.

The report in question was, for some unknown reason, not displaying all captions. It was a report with multiple data indented items. The strange thing was that when one of the data items was removed, the labels would show again. Let me give you an example. (fyi, this is a demo report I created for this blog)

Presume that you create a report, containing three data items:

When we run the report in the Classic Client we get this:

To be able to get this result I updated some records and made sure Annette Hilleee is the Salesperson for Customer IC1020 and the Purchaser for Vendor 01905283.

Now let’s create an RDLC layout.

You can import this layout using: Disappearing Labels v1

This is the layout at runtime:

Do you see the labels for the vendor data item? What happened?

Let’s have a look at the dataset:

Do you understand the problem? If not, have a look at the header in the vendor table (RDLC layout):

The function First gets no result, because those fields are empty in the dataset…

How can we fix this?

First of all, interesting to know is that a similar kind of problem occurs when you generate the RDLC layout using the option: Create Layout Suggestion. When you delete the RDLC layout, this is the “suggested” layout:

It seems that customers and vendors are not important enough to be suggested Happy

The solution for this is to move the labels from the customer and vendor header section to the (first) salesperson header section:

So, let’s try the same for or original report: Disappearing Labels v1.

Problem solved, no?

Not really. It works, but it’s a sub-optimal solution or what we consultants call a quick-fix Wink

Why? Well, because the report is now ‘broken’ when you run it in the Classic Client. (The layout is messed-up) Furthermore, performance-wise I believe it’s better not to have captions on all rows in the dataset, when you only need it once.

A solution would be to use an integer dataitem and put all captions on its section. Ofcourse, don’t forget to filter it: WHERE(Number=CONST(1))

As you can see, I prefer to put the integer (CaptionsRTC) at the end, so when I look at the dataset the captions are on the right side:

Be aware that the line in the dataset that contains the captions will cause an emptyline in the report to appear. (or even a blank page) To fix that you can apply a filter in the list:

Also think about the expression you use to fetch the captions. Because when you filter the list, the captions should be fetched using a dataset scope=Last(Fields!Customer__No__Caption.Value, “DataSet_Result“) If you omit the parameter: “DataSet_Result” the caption will not be found.

You can download the report here: Disappearing Labels2

Of-course, in this version of the report the layout in the Classic Client is now ‘fubar’.

As a solution you could hide the section CaptionsRTC using the following code in the OnPreSection trigger: CurrReport.SHOWOUTPUT(FALSE); And then add an integer dataitems for every data item that has to show captions in the Classic Layout of the report. In the OnAfterGetRecord trigger of those integer dataitems you should then use currReport.SKIP, otherwise you will end up increasing the dataset again with unnecessary stuff…

Summary:

  • If captions disappear in the RDLC layout of a report, then think about moving the labels/textboxes to the header section of the first data item. (the quick-fix approach)
  • If your report is experiencing performance issues or if you expect a big data set (more then 100.000 rows), then think about removing captions from all rows. There’s no reason to copy the same data for every row, not?
  • If you are working in mixed mode, meaning some users are still using the Classic Client, you might have to add extra integer data items, only for the Classic Client.

9 Thoughts on “Where are my captions?

  1. Pingback: andreas04: close to attraction

  2. Pingback: NAV 2009 RDLC Reporting: Working with multiple datasets - Waldo's Blog - Microsoft Dynamics NAV

  3. Pingback: NAV 2009 RDLC Reporting: Working with multiple datasets - Waldo's Blog Microsoft Dynamics NAV - NAV Technical Blogs - Microsoft Dynamics Community

  4. Once more: thanx for helping me out, Steven.

    [Only just todat I did hit upon your post and have added you to my blog list 😉 ]

  5. BTW: a nice way of illustrating the various steps in building the RDLC

  6. Steven on June 12, 2012 at 13:46 said:

    I’m always happy to help out 🙂

  7. Steven, is there an efficient way to get this “=Last(Fields!Customer__No__Caption.Value,”DataSet_Result”)” in a cell? I mean: if I drag and drop a dataset element from the Website Data Source pane on a table cell the designer will populate it with “=Fist(Fields!Customer__No__Caption.Value,)”.
    Now I have to manually change this for each cell to get “Last” and “DataSet_Result” in my expressions, which is quite tedious.

    • Steven on June 12, 2012 at 16:51 said:

      You’re correct, it’s a tedious task. It could help if you open the expression designer and add the field like this:
      InsertCaption

      But it still requires some manual intervention.

  8. Useful tip!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Post Navigation