Three ways to use extension data in C/Side

So, I get it now. We need to develop in extensions. Nothing but extensions. We need to tell our employers to forget about new requirements for half a year and ignore bugs while we developers lock ourselves in the basement and rework our existing code to an extension. Right?

Well, locking developers in a basement will probably appeal to a fair number of managers. Not developing new requirements or fixing bugs for said amount of time will definitely not. Like it or not, many of us face working with hybrid systems.

Where I work we now have extensions in a heavily modified C/Side code base. So when my Colleague phoned me a while back to ask me how in hell he could get a field from our extension onto a C/Side report I had to put my thinking cap on.

So far I came up with three workable methods of getting extension data into C/Side.

For demo purposes I created a simple extension that adds a Box Number field to the Posted Sales Shipment Header (110):

TEX50100

And adds in on the Posted Sales Shipments page (142):

PEX50100

So, I now have a Box No. field on my Posted Sales Shipments. How do I use it in C/Side?

Method 1

Create an eventpublisher in a C/Side Codeunit or Report and subscribe to it in the extension:

COD50208

COD50100

Now for example add a button on the Posted Sales Shipments Page that calls the Codeunit:

PAG142

And there you go:

MsgBoxFromEvent

Big downside here of course is that you have to generate symbols. Which is a right royal pain in the backside. So, without symbols and events?

Method 2.

Thanks to some old colleagues I have a pretty good working knowledge of RecordRefs and FieldRefs. So, can I use those?

COD50208-FieldRef

And again a call from page 142:

PAG142-FieldRef

And::: (drum-roll please)

MsgBoxFromFieldRef

So, well, that was, well, easy. Of course you would need to add a few checks to see if the field exists. Just in case someone uninstalls your extension.

Method 3.

Have I mentioned it gets easier? Well, I have been working with the great people at ForNAV for a while now. Since they use the fields web service to determine the Dynamics NAV data set perhaps the ForNAV designer can see the extension field without mucking about in hyperspace C/Side. So I converted report 208 to ForNAV and opened the designer:

BoxNoInForNAV

So, there it is. I added the BoxNo field to the report and when printing this is the result:

REP50208-ForNAVResult

Final notes

Thanks for reading this far. If you have anything to add or know of a better way please let me know. Of course all the objects and the extension are found on GitHub. All objects are provided without warranty. Try them at your own risk.

Full disclosure, ForNAV do pay me to do webinars and other stuff. I love the product because it is awesome. That is why I write about it. Try it, you will not be disappointed.

Lees ook:

Create a custom Email Scenario For Business Central

Today I had to send a specific email from Business Central from a specific backoffice account. Roberto Stefanetti has written...

A monumental event, part 2

I will show you a simple process that I have automated with the Azure Event Grid and Logic Apps, sending...

A monumental event, part 1

An introduction to event driven architecture in relation to Business Central. You will read about why I use serverless back...
ticket system
Skip to content