Monthly Archives: June 2020

Interfaces in AL (part 3)

This is 3. part from the article series about Interfaces in AL Language. See the first one or the second one.

In previous parts, I have described the basics of Interfaces in AL Language (what is an interface, how to work with them in AL and started working on advanced example).

In the last part, we will continue with our advanced example and will add Enums to use the whole power of Interfaces.

Enums

Enums are described in a separate article.

Example

So, we use our Advanced example from part 2 as a starting point hence those who haven’t read the second part yet, check it first. Now, we create Enum specifically for this example.

 enum 50100 "TKA Inspection File Type"
 {
    Extensible = true;
    
    value(0; " ")
    {
        Caption = ' ';
    }
    value(5; "TKA BLB Type")
    {
        Caption = 'BLB Type';
    }
    value(10; "TKA XXS Type")
    {
        Caption = 'XXS Type';
    }
 }

We have an Enum that is similar to the original Option Data Type. But what is the advantage of Enums? With Enums, we can specify an implementation for every value in the object using property Implementation.

Firstly, the Enum must implement an interface(s). Then for every value, we can define a Codeunit object that implements the interface for the specific value. If the Enum implements an interface all values must have concrete specification through defined Codeunit. We can use property DefaultImplementation that will be used for values that do not have implementation specification defined directly.

 enum 50100 "TKA Inspection File Type" implements "TKA Inspection Format"
 {
    Extensible = true;
    DefaultImplementation = "TKA Inspection Format" = "TKA Default Format";
    
    value(0; " ")
    {
        Caption = ' ';
    }
    value(5; "TKA BLB Type")
    {
        Implementation = "TKA Inspection Format" = "TKA BLB Inspec. Format Mgnt.";
        Caption = 'BLB Type';
    }
    value(10; "TKA XXS Type")
    {
        Implementation = "TKA Inspection Format" = "TKA BLB Inspec. Format Mgnt.";
        Caption = 'XXS Type';
    }
 }

And finally, how to use this implementation. With the old approach, there will be an Options field on a page to allow users to choose a format that they are importing. Then in the code, there will be if/case statement which decides based on selected option value which Codeunit should be run. That means if we want to add a new format, we would have to change existing code (that could be in a different extension and impossible to change!).

However, with Enums, we have an Enum field on a page to allow users to choose the format (the Enum which is extensible from other extensions). Then in the code, we create an interface variable and assign the selected value of Enum. Then we call the requested methods using the interface object. That means no change is required when we need to add new supported format.

 codeunit 50100 "TKA Import Management"
 {
    procedure ImportFile(SelectedInspectionFileType: Enum "TKA Inspection File Type"; FilePath: Text)
    var
        InspectionFormat: Interface "TKA Inspection Format";
    begin
        InspectionFormat := SelectedInspectionFileType;
        InspectionFormat.LoadFile(FilePath);
    end;
 }

Merge entity duplicity

In the case of duplicity in Customers, Vendors or Contacts, the system offers functionality to merge related record. To run it, go to the customer/vendor/contact card and run action “Merge With…”.

The setup window is opened for the entity from which the page was started. In the header, the opposite entity with which we want to merge has to be chosen, then the system lookup all relevant data and show them in the tab below.

In this tab, the user can see all conflict between the source entity and the selected one. If you want to save the value of any field from the selected entity, choose “Override”; otherwise, the value from the source entity will be used.

The last tab, “Related Tables”, shows all tables where the source or selected entity were found. The most important information is whether there are any conflicts in the column “Conflicts”. If there are any problems, in the next step it will be necessary to resolve them before the process of merging could be finished.

Whether there are any conflicts or not, continue with the action “Merge”. If there are some conflicts, resolve them and then run the “Merge” again. If there aren’t any, just confirm the merging process.

CU 2020/06 for Microsoft Dynamics NAV 2016 – 2018 and Microsoft Dynamics 365 Business Central on-premises has been released

The cumulative update 2020/06 for Microsoft Dynamics NAV 2016, NAV 2017, NAV2018 and for Microsoft Dynamics 365 Business Central (2019 wave 1, 2019 wave 2, 2020 wave 1) on-premises has just been released.

VersionLinks
Microsoft Dynamics NAV 2016/CU56DownloadDocumentation
Microsoft Dynamics NAV 2017/CU43DownloadDocumentation
Microsoft Dynamics NAV 2018/CU30DownloadDocumentation
Microsoft Dynamics 365 Business Central Spring 2019 on-premises/CU13DownloadDocumentation
Microsoft Dynamics 365 Business Central 2019 Wave 2 on-premises/U15.7DownloadDocumentation
Microsoft Dynamics 365 Business Central 2020 Wave 1 on-premises/U16.2DownloadDocumentation