A question I get asked frequently is: Ho Do I Create a Report in VSCode, and to me more specific, How Do I Create the Layout, being an RDLC or Word layout?

The answer is that you need to create the report object as an .al file, then you create and export the layout(s) and reference them from within the .al file.

So let’s get started.

In VSCode create a new project, using the AL:Go command:

In your project, create a new file, for example: MyReport.al. In the Report.al file, use the treport snippet to create a report and then change the ID, Name and add fields and an option page, as in the following example:

In this example I’m using fields from the Customer table to build the dataset for MyReport. I have also added a variable HideDetails, which I have also added in the Request Page.

Now you need to be able to run the report. For this, I will make an extension to the existing Customer List Page. Create a new .al file, like the following example:

In the launch.json file I’m using the Customer List, page 22, as my startupObjectId:

Now, when you publish the project, using F5, the application opens, the Customer List displays, and the new action is available in the Actions:

And when you Run it the following happens:

The Request Page displays, with the HideDetails Boolean.

Now this report does not have a layout, so it makes no sense to Send or Preview it.

Now we need to create a layout. You can do this in the application.

Go to the page: Report Layout Selection and filter on your report Id or Name:

Our new report is found and as you can see, it does not have a report layout. We will now create one for it.

Select Actions, Custom Layouts:

Then select: New:

In the window that opens, I select RDLC:

An empty RDLC layout is now added to my report:

Select Export Layout, to save it. Save it in your AL project, for example in a subfolder called ReportLayouts:

Now open this file using Report Builder, for example via a right click and the open with Report Builder:

In ReportBuilder you can now modify the layout:

For example, add a Table to create a list layout:

Then save the file.

Now in the MyReport.AL file you need to reference the layout, for example as follows:

Now when you run the report, you see the following:

Similary I will now add a Word layout to the same report. So in the application, go back to the Report Layout Selection page and add a Word layout:

Then export it:

Now open it in Word:

You can now create the Word layout and save it in the ReportLayouts folder:

Then you need to reference the file in your report:

And as you might have noticed, I have set the Word layout as the DefaultLayout.

Now when you redeploy the extension and run the report, you see:

And voila, that’s all it takes to add an RDLC and WORD layout to a report, using the new development environment, VSCode…

Feel free to download the example here:

Ok, granted, it works, but I find this procedure really cumbersome. Cumbersome, that’s a polite way of saying, it’s ***! So I hope, one day, there will be an easier procedure to achieve this, one for which we can do it all in VSCode. But until then…


6 Thoughts on “How Do I : Create a Report, and layout, in VSCode?

  1. No way… this cannot be for real. Someone needs to create a VSCode extension to make this easier…

    • That should be possible, since all of it is in existing NAV objects (creating and exporting the layouts…). At the moment I created a task in VSCode that runs Report Builder, that helps a little bit. I’m investigating how I could automate this process further…

  2. Considering that complicated reports require some back and forth with NAV logic changes and testing the layout, we really need a more integrated experience like we have currently. I can see this being useful if we can use this to make minor changes.
    We cannot expect wonders with release 12 though. Release 3 with NAV 2020 should be pretty good – lets hope they do not code name 2020 as Atlantis!

  3. Bill on August 8, 2017 at 00:20 said:

    I’m getting an error like the one in the following link: https://stackoverflow.com/questions/33554424/dynamics-nav-sql-server-report-builder-commandtext-property-has-not-been-ini

    So, I’m unable to test the report in ReportBuilder?
    I cannot run it and get results without going into NAV?

    • Hi Bill,
      No you can not run the report in Report Builder, you can only run it in Nav. The rdlc file only contains a description of the dataset, no data and no query. When Nav runs it, the data and layout are retrieved and sent to the report viewer which combines them to form the result.

  4. Pingback: How Do I : Create a Report, and layout, in VSCode? | PA

Leave a Reply

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

Post Navigation