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:

How-To “Hide the Page Inspection or Zoom for users” in Microsoft Dynamics Business Central

Scenario:

  • Users by default are allowed to access the data of Microsoft Dynamics Business Central (BC) which they can view the table or check the values which we some installations may not need.

Before Changes:

  • Users can access the said details either by pressing the [Ctrl] + [Alt] + [F1] on their keyboard or by going to ‘Help and Support’ -> ‘Inspect Pages and Data’
  • The screen looks something like shown below:

Solution:

  • Create a new Permission Set in BC as shown below:1
TypeObject TypeObject IDObject Name
ExcludeSystem1350Run Table
ExcludeSystem5330Tools, Zoom
Permissions under new Permission Set create.
  • Assign the permissions to the users and ask them to re-login in BC.

After Changes:

  • Now ask users to re-login to BC and they will not see the data under Page Inspection. The screen would look like below:

References:

  1. Define Granular Permissions – Business Central | Microsoft Learn ↩︎

Power BI – How to create and show customized ToolTips.?

Scenarios:

  • Default PowerBI report and dashboard shows values of default or select fields when you hover your mouse over.
  • You need to show a different ToolTips page.

Solutions:

  • Create a page and change its Canvas settings. Here change Type to ToolTips
If you see above, I have created a KPI page which picks data from Measure. 
  • Tick ‘Allow use as tooltip’ on Page Information of that page.
  • Select a visualization where you need customized tooltip to show. Go to General tab and select ToolTips to enable it. Under Type choose ‘Report page’ and select page of tooltip created with above listed steps 1 and 2:
  • Now you see Tooltips properties has been changed:
  • Output you’ll see is:

instead of

Reference Links: