Being a Navision/NAV person for some ages, and then Business Central person for a while also, I was so thrilled to see new – long time waited features coming up to BC with the wave 2021 w1. Microsoft Dynamics 365 Business Central Launch Event announced few really good stuffs among which, at least for me, new object type called report extension steal the show!
I am sure many NAV experienced (not old, of course) people remember the good old CSide’s Shift+F12 keystroke and two more clicks to reach the report design – both from data and UI perspective.
But then two “kinda” bad guys named RTC & AL came and took that lovely tool from us. And for several years I felt some discomfort in my stomach when client asked for just ONE additional column in their favorite reports. Yep, I “enjoyed” so much making copies of report just to add a column or two…
But it seems those days are over! What an intro for my first blog!
Now or finally, in the Business Central wave 1 2021, Microsoft responded to the cries of the community and introduced a new object type – very logical one – report extension.
The new object can extend the existing report to some extent:
- Create new columns
- Add new “nested” dataitem, not a new dataitem on the root level
- Add code to limited number of triggers: OnPreReport and OnPostReport
- Change a request page – add new fields and add the trigger code
- Pack the layout together with new report extension, which is then listed in report layouts when published.
Note – it is only possible to select layout types supported by the base report.
- Other ISV can make extension on the same report
So here is my try – my very own simple Hello World report extension.
The purpose of this small project was to test capabilities and not to solve some real client’s issue.
For demonstration, I took report number 3 – G/L Register in cloud BC and assume for me very common scenario – adding the Source Code column Journal Batch Name and removing some Posting Groups columns. And let’s add option to run another report after execution of the first one, just to demonstrate some capabilities.
Here is how it looks by the standard solution:
To extend the existing report G/L Register with few columns I needed to:
- Create new reportextension object
- Refer to new RDLC layout as I wanted to add new columns and remove existing one
- Under the dataset specify on which data set I am performing additive changes
- Specify the columns I wanted (I could add columns from tableextension if any, some calculations, calls on protected variable and procedures from the base report).
This worked fine in Visual Studio Code with some hassle around layout – handling layouts is just the same as it was before.
Then some more work on the request page… where I did not miss a chance for Hello World message.
Working on the request page is as before. I added my variable to be protected – accessible by other report extension, as I would preferred the same for this base report. It would boost extensibility.
My advice is do not trust IntelliSense always. It gave me modify option which is not supported in the reportextension. In request page, anchors were missing by IntelliSense, but luckily drill down to report definition worked.
Initially I tried to make some more useful scenario on a request page – like filtering the dataset beneath on the new field OnValidate trigger or to add some RequestFilterFields for example Posting Date on G/L Entry dataset. But that did not work – it resulted in an error when object was run. I guess those could be considered as destructive changes that Micosoft doesn’t allow for reportextension.
As there is a way to add code to OnPreReport and OnPostReport triggers, I added some code in the onPostReport trigger where based on the option from the request page, another report is run.
Then when I came to publishing – it worked fine after I gave up from “destructive” changes.
The only thing that you need to do after the extension is deployed is to point the report layout to the newly built in RDLC. This, of course, can be automated with some additional coding for the extension handling.
Here is the result – dataset and request page are extended:
The small demonstration reportextensions project is available in GitHub.
Seems like additive changes work nicely, but any other such as modification of existing columns or changing code in report trigger are consider as destructive and not supported.
So, this is not a story with the 100% happy end as there are more gaps that some of could get fit in the future. I would personally like txt2al tool to be enhanced with reportextension so to make migration pains easier and also some magic with the layout please!
At the end, I just want to briefly mention some other features that took my attention, but haven’t tested it yet:
- Returning types for methods
We are aware that we could never return some types from methods such as record type, codeunits… but now we can. The only unsupported return type for now is File. I think we can live with that.
- Adding a new tables keys through the table extensions
Have you ever been missing a key in base tables? Not anymore! Now you can extend the base table key with the other base table field. Hmmm… yeah still missing some extensibility here, but this will work also.
Hope this joy will last long and similar long waiting improvements are just around the corner… just hope that the next steps of BC architecture modernizations and moving to .Net core won’t break the party!
Be free to reach me back about any technical questions about Dynamics Business Central.
The blog post is written by Merana Sadikovic Mandzukic, Consultant Business Applications, Sopra Steria.
Sopra Steria är ett ledande internationellt konsultföretag inom digital transformation med en av marknadens mest omfattande tjänsteportföljer. Bolaget erbjuder allt från dataanalys, affärs- och verksamhetsutveckling via projekt- och förändringsledning till systemutveckling, testning, driftsättning och daglig förvaltning av IT-system. Med kunskap och erfarenheter från många olika branscher och med hög teknisk kompetens, hjälper Sopra Steria privata och offentliga organisationer i Skandinavien med att ta ett digitalt ledarskap.
Koncernen har drygt 46 000 medarbetare i 25 länder och hade en omsättning på € 4,3 miljarder 2020. I Skandinavien har bolaget drygt 2 500 medarbetare och omsatte tillsammans 3,5 miljarder kronor 2020.
Med passion för människor och teknik skapar vi en bättre framtid tillsammans. The world is how we shape it.
Sopra Steria (SOP) är börsnoterat på Euronext Paris (Compartment A) – ISIN: FR0000050809.