How to identify subscriber events in Dynamics 365 Business Central?

Hi ALL,

Eventing is major part while upgrading to business central, we face alot of customisation done in Customer database which needs to be evented and converted into extension.

You subscribe to events to extend application and interact with the base application and other extensions. This topic describes how to discover events that you can subscribe to without writing the code manually

I suggest you to see the topic mentioned below before moving further on this

Why Event & Extensions for Microsoft Dynamics 365 Business Central (MSDYN365BC)? 

I have got some query about how to identify the EventSubscriber for AL code. So lets take a dive into this.

Record Events

To record the current session, Search for Event recorder in Business Central click the Start button located on the actions ribbon.

After starting the Event Recorder do not close the Window, open the session in different window.

Perform all the actions that you want to record while the Event Recorder session is on. For example, we want to make External Document No. Mandatory in Sales Order (which is default feature)

I will try to post the Sales Order and check go to Event Recorder window and stop

You will get the list of Event occured while doing this activity as shown below

You can directly copy the event subsciber code from GET AL Snippet

Copy the EventSubscriber and add a new Codeunit as mentioned in Why Event & Extensions for Microsoft Dynamics 365 Business Central (MSDYN365BC)? 

You can ref for some more example on Events mentioned below.

Part 1 of this topic:How can we flow a custom field from Journal to Ledger for AL project in VS Code for MSDYN365BC.

Part 2 of this topic:How can we flow a custom field from Journal to Ledger for AL project in VS Code for MSDYN365BC continued..

To get new updates and learn about Microsoft Dynamics 365 Business Central Microsoft Learn and Self Learning

Download Link for different version of NAV and Business Central

Happy Reading.

Creating a Word Layout Report in Microsoft Dynamics 365 Business Central MSDYN365BC

Hi ALL,

HAPPY NEW YEAR !!

In todays blog we will be discussing about Creating Word Layout in Business Central MSDYN365BC

If you want to Create RDLC Layout then ref to my previous blog

Creating an RDL Layout Report in Microsoft Dynamics 365 Business Central (MSDYN365BC).

So lets begin with Creating a AL File For the Word Layout

AL file for WORD LAYOUR in MSDYN365BC

As shown below New report is being create with DefaultLayout As WORD for Item Table

I have added few fields for demo purpose, you can add fields according to your need.

After creating the AL File, build the extension (Ctrl+Shift+B) to generate the MyWordReport.docx file.

Create PAGE Extension in MSDYN365BC

I have creeated page extension of Item List page and added the report to Run on Open Page event, so when you go on Item List this report will run.

You can specify you report to run on Action as well.

Open the Word report layout document in Word.

Once the MyWordReport.docx file has been open in Word layout enable the Developer TAB

If you do not see the Developer tab, go to Options, then Customize Ribbon, and in the Main tabs section, select the Developer check box as shown below.

On the Developer tab, choose XML Mapping Pane, in the Custom XML Part dropdown list, choose the custom XML part for ADD INCLUDE report, . The name of the custom XML part has the following format

urn:microsoft-dynamics-nav/reports/report_name/ID

Add data field in Word Layout in MSDYN365BC

  1. Add Table with 4 column and 2 rows
  2. Right-click on the Item table, and in Insert Content Control, select Repeating to add the repeater data item in the 2nd row
  3. Right-click on the field and in Insert Content Control, select Plain Text to add the column as a text box.

Save the report layout when you are done and then close it.

Back in Visual Studio Code, press Ctrl+F5 to compile and run the report.

Now open the Client and run Item List, and Report will be Run while opening the List and You can preview it as shown below.

To get new updates and learn about Microsoft Dynamics 365 Business Central Microsoft Learn and Self Learning

Download Link for different version of NAV and Business Central

Happy Reading.

Creating FactBox in Microsoft Dynamics 365 Business Central

Today, I was working on new Merging for Upgrade to Business central and i came across FACTBOX in Business Central. So i thought of sharing this with you.

Factbox area is normally located on the Left side of the page and is used to display content including other pages, charts, and system parts such as Notes, and Links.

Creating a factbox can be done in two steps.

  1. Creating a factbox Page
  2. Adding a FactBox area to a page

Creating a factbox Page

ItemDetailsFactbox in MSDYN365BC

Here i have Created a new page of type CardPart with Sales Line Table to display Item No. Description adn Unit Price in the Fact box.

I have added a local procedure to display the same when the Type in the Sales line is Item.

Adding a FactBox area to a page

Link Sales Order Lines to ItemDetailsFactbox in MSDYN365BC

I have extended Sales Order Page and added FactBox with link on Sales Lines

Compile and Run will give you output as shown in below screen shot.

FactBox in Business Central MSDYN365BC

You can ref:

How to Connect Dynamics 365 Business Central 2019 Release Wave 2 to Visual Studio Code (MSDYN365BC).

How to Set up VS Code to Docker in Microsoft Dynamics 365 Business Central wave 2 Release (MSDYN365BC)

To get new updates and learn about Microsoft Dynamics 365 Business Central Microsoft Learn and Self Learning

Download Link for different version of NAV and Business Central

Happy reading

How can we flow a custom field from Journal to Ledger for AL project in VS Code for MSDYN365BC continued..

Hi ALL,

If you have not seen part 1 of this topic. How can we flow a custom field from Journal to Ledger for AL project in VS Code for MSDYN365BC.

So moving further with this topic we have seen

  1. Adding Field in Table as Table Extension
  2. Adding fields in Page as Page Extension
  3. Adding Code as Subscription in Codeunit.

Now lets move further.

3. Adding Code as Subscribtion in Codeunit in MSDYN365BC.

You can add New Codeunit and provide the event Subcriber

[EventSubscriber(ObjectType::<Event Publisher Object Type>, <Event Publisher Object>, '<Published Event Name>', '<Published Event Element Name>', <SkipOnMissingLicense>, <SkipOnMissingPermission>)] 
EventSubscriber in MSDYN365BC

I have added Procedure OnBeforeInsertCapLedgEntry

ArgumentDescriptionOptional
<Event Publisher Object Type>Specify the type of object that publishes the event. This can be CodeunitPageReportTable, or XMLPort.no
<Event Publisher Object>Specify the object that publishes the event. You can set this to the ID, such as 50100, or the recommended way is to use the object name by using the syntax <Object Type>::"<Object Name>", such as Codeunit::"MyPublishers", or for database triggers Database::"Customer".no
<Published Event Name>Specify the name of method that publishes the event in the object that is specified by the <Event Publisher Object> parameter.no
<Published Event Element Name>Specifies the table field that the trigger event pertains to. This argument only requires a value for database trigger events, that is, when the <Event Publisher Object Type> is set to Table and the <Published Event Name> argument is a validate trigger event, such as OnAfterValidateEvent.no
<SkipOnMissingLicense>Set to true to skip the event subscriber method call if the user’s license does not cover the event subscriber codeunit. If false, an error is thrown and the code execution stops. false is the default.yes
<SkipOnMissingPermission>Set to true to skip the event subscriber method call if the user does not have the correct permissions the event subscriber codeunit. If false, an error is thrown and the code execution stops. false is the default.yes

Try to post an output journal with Long Description and you can view the Long Description in Capacity Ledger entry after posting.

Self Learning Link by microsoft.

To get new updates and learn about Microsoft Dynamics 365 Business Central Microsoft Learn

Thanks for reading.

How can we flow a custom field from Journal to Ledger for AL project in VS Code for MSDYN365BC.

Hi All,

While doing upgrade to Microsoft dynamics 365 Business Central it is important to Event the code which are done in NAV Base objects.

So lets take an example where Field will be passed to Ledger entries.

Customer has requirement to add a Long Description in Output Journal and that needs to be displayed in Capacity ledger entry.

How can we flow a Long Description field from Output Journal to Capacity Ledger in Business Central ?

This will be done in 3 steps

  1. Adding Field in Table as Table Extension
  2. Adding fields in Page as Page Extension
  3. Adding Code as Subscription in Codeunit.

1. Adding Field in Table as Table Extension in MSDYN365BC

So lets see how to add field in Table as Table Extension in MSDYN365BC

Create a table Extension for Item Journal Line and Capacity Ledger entry and add field Long desc as text and length 100.

New Fields has been Created on id 50100

2. Adding Field in Page as Page Extension in MSDYN365BC

Create Page extensions as shown in below screen shot and add fields in the pages Output Journal and Capacity Ledger Entries as shown in below Screenshot. The fields will be added after the Scrap Code in the page.

So this is how we add fields in tables and pages, in next blog i will mention about Subscriber for posting codeunit.

You can ref:

How to Connect Dynamics 365 Business Central 2019 Release Wave 2 to Visual Studio Code (MSDYN365BC).

How to Set up VS Code to Docker in Microsoft Dynamics 365 Business Central wave 2 Release (MSDYN365BC)

To get new updates and learn about Microsoft Dynamics 365 Business Central Microsoft Learn

How to View a table object from an AL project in Visual Studio Code for MSDYN365BC

Hi ALL,

While developing a report in VS code for MSDYN365BC, i was stuck when i wanted to run the Table in AL code, it was very simple in C/AL. So how can we view Table data in AL code where we dont have Development Env?

In a development environment, in addition to viewing a table directly from the Web client, developers, administrators, and support personnel can view a table automatically when they publish/debug an AL project from Visual Studio Code.

There are three methods to Run the Table.

You can view the table directly from web client by below mentioned url.

If i want to run Item Table and check the records in the Table

http://localhost:8080/BC150/?table=27

View a table object from an AL project in Visual Studio Code

In the launch.json file for the project, set the “startupObjectType” parameter to “table” and the “startupObjectId” parameter to the ID of the table. For example.

View a table object from an AL project in Visual Studio Code through AL object designer.

You can instal AL object designer in VS Code.

Go to Command Pallet (Ctrl + Shift +P) and run AL Object designer.

You can Objects from the AL Object designer.

This are few tips to View a table object from an AL project in Visual Studio Code for MSDYN365BC

You can ref:

How to Connect Dynamics 365 Business Central 2019 Release Wave 2 to Visual Studio Code (MSDYN365BC).

How to Set up VS Code to Docker in Microsoft Dynamics 365 Business Central wave 2 Release (MSDYN365BC)

To get new updates and learn about Microsoft Dynamics 365 Business Central Microsoft Learn

Thanks for reading.

Page Background Tasks in Microsoft Dynamics 365 Business Central 2019 release wave 2 continued..

Hi All,

A page background task is a child session that runs processes from a codeunit in the background, letting the user continue working on the Parent page session while the task runs. 

If you are new to PAGE Backgroung Task for basic understanding you can refer Page Background Tasks in Microsoft Dynamics 365 Business Central 2019 release wave 2

Let understand this by taking an AL Code example.

Customer has a requirement to display the Count of Posted Sales Invoice for a Customer on Customer card.

This can be done in 2 steps.

  1. Create Page Background Task on Page:
  2. Create a background task codeunit.

Create Page Background Task on Page

We will first create Page Extension for Customer Card.

We will add a Text Var to display “Posted Sales Invoice Count” on Customer card and add the same in General Tab .

Customer Card Ext for Page Background Task in MSDYN365BC.

Add EnqueueBackgroundTask

When a page background task is enqueued, parameters are passed as a dictionary of text to the codeunit’s OnRun trigger when the page background task session is started.

EnqueueBackgroundTask in Msdyn365bc

OnPageBackgroundTaskCompleted Trigger

OnPageBackgroundTaskCompleted trigger of the page in the parent session is called, and the results of the task are passed to the trigger. The results are passed as a dictionary of text.

OnPageBackgroundTaskCompleted in Msdyn365bc

OnPageBackgroundTaskError Trigger

When an error occurs in the page background task codeunit, this trigger of the page in the parent session is automatically called and we need to handle the error.

OnPageBackgroundTaskError in Msdyn365bc

Create a background task codeunit.

You need to create a new codeunit which will do all the calculation and run it in background. After the calculation have been performed the it needs to be passed back to the calling page for handling through SetBackgroundTaskResult and get data from Parent session through GetBackgroundParameters .

PageBackgroundTask Codeunit in Msdyn65bc

This was complete overview of the process. You can try this and improve the performace of the pages.

You can download the code from GIT.

For more details you can read Best Practices for AL Coding in Microsoft Dynamics Business Central (MSDYN365BC)

To get new updates and learn about Microsoft Dynamics 365 Business Central Microsoft Learn

Thanks for reading.