April 24, 2012

Converting Dynamics NAV Classic Reports To RDLC – Part 2

The Basic Report Conversion Process

First, we might as well be up-front: the basic process of converting Dynamics NAV classic reports to RDLC layouts is clunky, time-consuming, and somewhat error-prone. This is caused in large part because you have to repeatedly work back and forth between the NAV classic report designer and the Visual Studio report designer (if you don’t understand why, see Converting Dynamics NAV Classic Reports To RDLC – Part 1).

The best way to demonstrate this is with a walk-through of the simplest possible report: a two-column (Code and Name)  list of salespeople that looks like this in the classic Print Preview:

f149a4 175a7252fab448fca4a146a0d897298a mv2

The report has no true header or footer, no global variables or C/AL code, no hidden fields – no complications whatsoever. It also has no RDLC layout, meaning it can only be run in the NAV classic client.

To create an RDLC layout, you have to first open the report in the classic report designer. NAV then provides us with two menu options:

  1. View->Layout; or
  2. Tools->Create Layout Suggestion.

If you choose View->Layout, NAV will either open the report’s existing RDLC layout, if one exists, or create a new blank RDLC layout.

If you choose Tools->Create Layout Suggestion, NAV will attempt to create a new RDLC layout based on the report’s classic layout, overwriting the existing RDLC layout, if any (though it will first request your permission to do so).

In either case, NAV will launch the Visual Studio Report Designer and load the RDCL layout in effect. For now, choose option # 2, the Create Layout Suggestion, which should result in the following Visual Studio Report Designer screen:

f149a4 cacf83b52f3746cb85f544af5dfd308b mv2

Naturally, the first thing you’ll want to check is how the report looks with its new RDLC layout, but here you run into your first challenge: there’s no way to preview the report from this environment. What you have to do instead is:

  1. Click File->Save Report.rdlc in the Visual Studio Report Designer.
  2. Switch back to the data items form of the classic report designer.
  3. Click the data items form, giving it focus (that’s the trigger for the next step in the process).

NAV will then respond with the following form:

f149a4 2d45b7c3f8174890a2ad7f55c174fbfc mv2

Click  “Yes” to this question.

What are you answering “yes” to? You’re loading the RDLC layout saved in the Visual Studio Report Designer into the classic report object.

Loading is not the same as saving and compiling, however, so if you want to properly complete the process, you will have to click File->Save in the NAV classic report designer and make sure the “Compiled” box is checked.

Where’s your RDLC report preview? Still not there yet. To this point, all we’ve done  is ensure that the RDLC layout we saved in Visual Studio is the same as the one we’ve saved in the NAV report object, i.e. we’ve put them in sync.

With your report properly saved, you have to type the following at the Windows command prompt: “DynamicsNAV:////runreport?report=XXXXX”, where you replace “XXXXX” with your report ID. Note, this form of the command is dependent on the availability of a local service tier. If you’re missing said tier, you’ll have to run a more specific form of the command, as follows: DynamicsNAV://server/service/company/runreport?report=XXXXX, where you replace the bolded elements with your NAV server name, service, and company, in addition to providing the correct report ID.

Do all this correctly and you will be rewarded with the RDLC Report Viewer preview of your report, as follows:

f149a4 1ecf9fbb2c9e4f6685a99ab86932b5e9 mv2

Now picture doing this for every review cycle (i.e. every time you want to preview a change you’ve made to an RDLC report), and you’ll understand why we refer to the process as “clunky”. It’s not as bad as it seems, mind you. After a while, your fingers get pretty quick at such repetitive tasks, but that, of course, can cause other problems…

Beware the Gotchas

There’s a reason we just dragged you through the preceding process loop, and it’s not because we’re sadists. Look again at the steps involved:

  1. Open report in classic report designer.
  2. View or create an RDLC layout and load it into the Visual Studio Report Designer.
  3. Perform layout work in Visual Studio. When you’re finished, save the Report.rdlc file.
  4. Switch back to the classic client, click on the data items form.
  5. NAV will ask you if you want to load the changes made to the RDLC layout. Say yes.
  6. Click File->Save to save and compile the report.
  7. Use the Windows run command to launch a preview of the updated RDLC version of the report (you can alternatively provide access to a report by putting it in a menu on a page in the RTC, but that won’t do much to shorten the process).

Now consider for a moment what will happen if you make changes during Step 3 of the process, save these changes in Visual Studio, then make some more changes, then switch back to the classic report designer without saving your second set of changes. NAV will still inform you that the RDLC layout was changed by Visual Studio. You will no doubt proceed to save and compile the report. But when you run a preview of the report, it will not render the report based on your latest version in Visual Studio. It will render it based on the version you last saved in Visual Studio, i.e. excluding any changes you made after that point (which may well be more your fault than NAV’s, but keep in mind the messages give you no clue; in fact, they go a long way to reassure you that all is well).

This may seem like a small issue, and indeed NAV will prompt you to close and save your layout in Visual Studio when you attempt to close the classic report, but if you’re new to the Visual Studio Report Designer and need to go through a lot of change/review loops during development, this type of gotcha can seriously mess up your debugging process.

So the moral of this post is: be careful in this environment, because it’s not only clunky – it’s a bit tricky, too.

Next Post

In the next post, we’ll undertake our first conversion of an existing NAV classic report into its RDLC counterpart, and begin showing you some of the problems you’ll encounter, as well as how to fix those problems.

Tags

Article written by Liberty Grove Software
Liberty Grove Software grew out of its predecessor company, Studebaker Technology, which in 1996 became one of the first Navision developer/resellers in North America (Navision was the predecessor to Microsoft Dynamics 365 Business Central/NAV). As you can tell from our website, we focus exclusively on Business Central/NAV. Almost all our certifications, third-party add-ons, associates, services, and projects are Business Central/NAV-related. This is intentional because we want to offer only the highest caliber expertise to our clients, and we feel we can achieve this only if we devote ourselves to one ERP product.
cross
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram