What’s New in “ErrorInfo datatype” for Microsoft Dynamics Business Central for Developers

Usage:

  • This blog shows to use error messages in different ways possible.
  • If you’re developing App for AppSource and want to give more detailed error message plus advanced capabilities to solve the error by end-users on their own.

Use Cases with examples:

1. ErrorInfo.Create (not a data type but as a direct function)-

  • When used with Error() do not make any difference and will show below error.
pageextension 50100 CustomerListExt extends "Customer List"
{
    trigger OnOpenPage();
    begin
        Error('App published: Hello world');
        //OR
        Error(ErrorInfo.Create('App published: Hello world'));
    end;
}
  • Output:

2. ErrorInfo (as a data type with MessageType as Client)-

  • Purpose: To show the specific error message same as above use case and sends to telemetry.
  • Code:
pageextension 50100 CustomerListExt extends "Customer List"
{
    trigger OnOpenPage();
    begin
        // Error(InitialMsg);
        // Error(ErrorInfo.Create(InitialMsg));
        InitializeClientError();
    end;

    local procedure InitializeClientError()
    var
        InitializeErrorInfo: ErrorInfo;
    begin
        InitializeErrorInfo.DataClassification(DataClassification::SystemMetadata);
        InitializeErrorInfo.ErrorType(ErrorType::Client);
        InitializeErrorInfo.Verbosity(Verbosity::Error);
        InitializeErrorInfo.Message(InitialMsg);
        Error(InitializeErrorInfo);
    end;

    var
        InitialMsg: Label 'App published: Hello world';
}
  • Output: Same as case # 1.

3. ErrorInfo (as a data type with MessageType as Internal)-

  • Purpose: To show some generic error message same as above use case and sends to telemetry. Mainly for developers track this error message.
  • Code:
pageextension 50100 CustomerListExt extends "Customer List"
{
    trigger OnOpenPage();
    begin
        InitializeInternalError();
    end;

    local procedure InitializeInternalError()
    var
        InitializeErrorInfo: ErrorInfo;
    begin
        InitializeErrorInfo.DataClassification(DataClassification::SystemMetadata);
        InitializeErrorInfo.ErrorType(ErrorType::Internal);
        InitializeErrorInfo.Verbosity(Verbosity::Error);
        InitializeErrorInfo.Message(InitialMsg);
        Error(InitializeErrorInfo);
    end;

    var
        InitialMsg: Label 'App published: Hello world';
}
  • Output:

4. ErrorInfo (with Title)-

  • Purpose: To show some error message with a title.
  • Code:
pageextension 50100 CustomerListExt extends "Customer List"
{
    trigger OnOpenPage();
    begin
        InitializeClientError();
    end;

    local procedure InitializeClientError()
    var
        InitializeErrorInfo: ErrorInfo;
        ErrorTitleLbl: Label 'Initializing error.';
    begin
        InitializeErrorInfo.DataClassification(DataClassification::SystemMetadata);
        InitializeErrorInfo.ErrorType(ErrorType::Client);
        InitializeErrorInfo.Verbosity(Verbosity::Error);
        InitializeErrorInfo.Message(InitialMsg);
        InitializeErrorInfo.Title(ErrorTitleLbl);
        Error(InitializeErrorInfo);
    end;

    var
        InitialMsg: Label 'App published: Hello world';
}
  • Output:

5. ErrorInfo (with Action)-

  • Purpose: To show some error message with a action and title.
  • Code:
    • Add InitializeErrorInfo.AddAction(UpdateLbl, Codeunit::”Update MNK”, ‘UpdateOnCustomer’);
local procedure InitializeClientError()
    var
        InitializeErrorInfo: ErrorInfo;
        ErrorTitleLbl: Label 'Initializing error.';
        UpdateLbl: Label 'Make Update';
    begin
        InitializeErrorInfo.DataClassification(DataClassification::SystemMetadata);
        InitializeErrorInfo.ErrorType(ErrorType::Client);
        InitializeErrorInfo.Verbosity(Verbosity::Error);
        InitializeErrorInfo.Message(InitialMsg);
        InitializeErrorInfo.Title(ErrorTitleLbl);
        InitializeErrorInfo.AddAction(UpdateLbl, Codeunit::"Update MNK", 'UpdateOnCustomer');
        Error(InitializeErrorInfo);
    end;
codeunit 50100 "Update MNK"
{
    trigger OnRun()
    begin
    end;

    procedure UpdateOnCustomer(ErrorInfo: ErrorInfo)
    var
        SomeProcessesLbl: Label 'Some process or data updates here.';
    begin
        Message(SomeProcessesLbl);
    end;
}
  • Output:

6. ErrorInfo (with Navigation)-

  • Purpose: To show some error message with a navigation, action and title.
  • Code:
    • Add InitializeErrorInfo.AddAction(UpdateLbl, Codeunit::”Update MNK”, ‘UpdateOnCustomer’);
local procedure InitializeClientError()
    var
        InitializeErrorInfo: ErrorInfo;
        ErrorTitleLbl: Label 'Initializing error.';
        UpdateLbl: Label 'Make Update';
        ActualUpdateLbl: Label 'Make Actual Update';
        NavigateToCardLbl: Label 'Open Card';
    begin
        InitializeErrorInfo.DataClassification(DataClassification::SystemMetadata);
        InitializeErrorInfo.ErrorType(ErrorType::Client);
        InitializeErrorInfo.Verbosity(Verbosity::Error);
        InitializeErrorInfo.Message(InitialMsg);
        InitializeErrorInfo.Title(ErrorTitleLbl);

        //Add actions using another codeunit
        InitializeErrorInfo.AddAction(ActualUpdateLbl, Codeunit::"Update MNK", 'ActualUpdateCustomer');

        //Add navigation action using another codeunit
        Rec.FindFirst();
        InitializeErrorInfo.PageNo(Page::"Customer Card");
        InitializeErrorInfo.FieldNo(Rec.FieldNo(Blocked));
        InitializeErrorInfo.RecordId(Rec.RecordId);
        InitializeErrorInfo.AddNavigationAction(NavigateToCardLbl);
        Error(InitializeErrorInfo);
    end;
codeunit 50100 "Update MNK"
{
    trigger OnRun()
    begin

    end;

    procedure ActualUpdateCustomer(ErrorInfo: ErrorInfo)
    var
        Customer: Record Customer;
    begin
        Customer.FindFirst();
        if Customer.Blocked = Customer.Blocked::" " then
            Customer.validate(Blocked, Customer.Blocked::All)
        else
            Customer.validate(Blocked, Customer.Blocked::" ");
        Customer.Modify();
    end;
}
  • Output:

Important Notes:

  • You cannot have two actions at the same time.
  • Any actions you put should have reference to global function of that Codeunit.
  • Try other functions like DetailedMessage for Telemetry.
References:

New Feature to “Add Item tracking lines from Item Journal lines” on Microsoft Dynamics Business Central (aka from v22.0)

Scenario:

  • It was hard to insert item tracking lines for item journals as they are saved in different table. Plus going to each journal lines and then inserting a lot/serial is a huge manual task.

Before Enabling:

  • The user needs to click on Item Tracking Lines and then enter Lot/Serial for that item (which needs to be done for all items if list is huge):

Solution:

  • On journal batches, enable the setup as shown in below snapshot.

After Enabling:

  • Four fields (highlighted below) would be shown on Item Journals Line (you must have seen them in Item Reclassification Journals).
  • Entering the data or uploading the data here allows to create a Item Tracking Lines in background.
  • This helps in uploading opening inventories in easier manner for items with lots / serials.
  • Same feature is available on Warehouse physical journal. Give it a try!!

Reference:

Short Review – Microsoft Dynamics Business Central – Release Wave 1, 2021 – Item Availability by Lot

Story:

Microsoft Dynamics Business Central Wave 1, 2021 included item availability by lot after approximately 90 votes on this idea. We will go through the functionality introduced, how it was done, pros and cons of module.

What’s New:

Microsoft Business Central Wave 1 2021
Microsoft Business Central Wave 2 2020

How:

  1. New buffer table ‘Availability Info. Buffer’, a matrix page and couple of queries to retrieve Lot from item ledgers and reservation entries.

Pros:

  1. Easily lists serial/lot number of items to determine the expiration, inventory, availability, requirements on single page.

Cons or Suggestions:

  1. Includes items with no item tracking codes on Item No filter (that can be considered).

Reference: https://docs.microsoft.com/en-us/dynamics365-release-plan/2021wave1/smb/dynamics365-business-central/monitor-inventory-transaction-availability-lot-window

Comment your feedbacks, suggestions or greetings!! 🙂

/*Stay safe*/