Reports, one of the most important aspects of an ERP and of course are widely used through the application. The layout of reports works the same in Business Central as that of NAV. You can use RDLC or Work Layout, the difference is, of course, the AL file like any other object. Apart from this, a major change or drawback is that reports cannot be extended. Yes, you heard it right! Microsoft hasn’t come with report extensions yet but we surely have some workarounds that will help us overcome this drawback.
In this blog, we’ll look
into the following:
1. Create a new report
2. Modifying this custom report
3. Modifying layout of an existing report
wherein modification is required only in the layout.
4. Modifying an existing report wherein modification is required in AL like adding a new field to its dataset (Workaround since reports are not extendable)
Note:
I’ll be taking the RDL Report Layout in consideration for this one.
Let’s look at these, one
by one.
Create a new
report
For creating a report from
scratch, you need an AL file and RDLC/Word Layout. Create a new workspace or use
your existing workspace and create a new .al file. For the layout, create a
folder in that workspace and create a .rdl file with a relevant name and
associate it to your AL file by using the property RDLCLayout. The AL
file looks like this:
You can then go ahead and
add relevant dataset, data items, columns, triggers or actions then open your
created layout in SQL report builder and design it accordingly. You can also run
this report by creating a Page Action. Build (Ctrl+Shift+B) and run (Ctrl+F5)
Note: If
you only have a .rdl custom Layout, then add this to your Report Layout folder
and modify .al file accordingly.
Know more about Reports
in AL: Report
Object
Modifying this
custom report
Whenever you want to make modification in your custom
objects, it is the same like any other object in AL.
Modifying layout
of an existing report wherein modification is required only in the layout
Whenever there is a requirement for which you only have
to change the layout and format an existing report, provided no additional
dataitems or customizations are required apart from the existing ones, you can
use an existing feature ‘Report Layout Selection’. Business Central has this
page wherein you can search for relevant Report, Export it, makes changes in
the Layout and Import the modified layout.
Activities involved are the same as NAV and following are the brief steps:
- Open Report Layout Selection
· Select this report and Perform the Actions: Custom Layouts > New > Tick RDLC Layout Checkbox > OK
· Way 1: Edit the Layout by clicking ‘Edit Layout’ action and save it
· Way 2: Export Layout, Modify it in SQL Report Builder > Import Layout
Modifying an
existing report wherein modification is required in AL
Like any other objects, reports
cannot be extended. But what if adding a new field to its dataset or custom
code is required? You will, of course, get the layout using Report Layout selection
as explained above. But what about the AL file? For that it is required to create
a new report. With this, does it mean writing your AL file from scratch even if
all I want to do is add just DataItem? Scary and time-consuming!
Well, don’t get paranoid,
there is a workaround and following are the steps:
· ==>Export relevant Layout (As explained in
the previous part)
==>Create a new .al file and add this report
to your Workspace > Report Layout (As explained in the first part)
Note:
This
will not create a new .rdl file but the one that you have added.
· ==>Now that you have the workspace and layout
ready, open Object Designer and search this relevant report for which you have
added the layout.
· ==>This will open an AL file, copy everything
except for the report ID and Report Name and paste it in your newly created AL
file
· ==>Change the RDLCLayout path as per
your new report.
· ==>Compile and build
· ==>Add customizations to your code and layout
· ==>Build and Run
No comments:
Post a Comment