Business Central 2023 wave 2 (BC23): Add option to specify tooltips for Notification/ErrorInfo actions (AddAction supports tooltips)

Dynamics 365 Business Central

Hi, Readers.
Dynamics 365 Business Central 2023 wave 2 (BC23) is generally available last week. More details: General availability: Dynamics 365 Business Central 2023 release wave 2 (BC23)
And all the sessions of Business Central Launch Event (2023 release wave 2) are available now!

I will continue to test and share some new features that I hope will be helpful.

In this post, I would like to talk about Add option to specify tooltips for Notification/ErrorInfo actions. This is not yet documented in the Business Central 2023 release wave 2 (BC23) release plan. But it is mentioned in AL Language extension changelog Version 12.0

From Business Central 2023 wave 1 (BC22), developers can set the Title property on Error dialogs that are presented to the user to enrich issue description. On top of that, using the ErrorInfo object, developers can add up to three custom actions that will be displayed on the Error dialog to provide users with corrective actions. More details: Business Central 2023 wave 1 (BC22) new features: Provide Title and custom actions to Error dialogs (Custom Actions in error messages)

As you might know, we can use ToolTip Property to set the string used for the tooltip of an action, a field, a FactBox, or an activity button. For example,

But there is no way to set this property on ErrorInfo actions, so as of BC22.x, tooltip is not supported. With this wave (BC23), Microsoft solved this problem.

In ErrorInfo.AddAction(Text, Integer, Text) Method and ErrorInfo.AddNavigationAction() Method, Microsoft added a new Description: Text parameter.

More detaiils:

For example,

Great. Give it a try!!!😁
From now on, Microsoft recommends to stop using the old Error method and use the new noe that uses ErrorInfo.

My test code:

pageextension 50100 CustomerListExt extends "Customer List"
{
    actions
    {
        addfirst(processing)
        {
            action(RunErrorAction)
            {
                Caption = 'Run Error Action';
                Promoted = true;
                PromotedCategory = Process;
                PromotedIsBig = true;
                PromotedOnly = true;
                ApplicationArea = All;
                Image = ExecuteBatch;
                trigger OnAction()
                begin
                    TestErrorAction();
                end;
            }
        }
    }
    local procedure TestErrorAction()
    var
        ZYErrorInfo: ErrorInfo;
    begin
        ZYErrorInfo.DataClassification(DataClassification::SystemMetadata);
        ZYErrorInfo.ErrorType(ErrorType::Client);
        ZYErrorInfo.Verbosity(Verbosity::Error);
        ZYErrorInfo.Title('This is New Error Title!!!');
        ZYErrorInfo.Message := 'This is Error Message';
        ZYErrorInfo.PageNo := Page::"Item List";
        ZYErrorInfo.AddAction('Error Action', Codeunit::"Error Action Test", 'Test01', 'This is Error Action tooltip');
        ZYErrorInfo.AddNavigationAction('Open Item List', 'This is Error NavigationAction tooltip');
        Error(ZYErrorInfo);
    end;
}
codeunit 50111 "Error Action Test"
{
    procedure Test01(ZYErrorInfo: ErrorInfo)
    begin
        Message('Test 01');
    end;
}

PS: The same method can also be used for Notification.AddAction(Text, Integer, Text) Method, but as of now (2023.10.12), the tooltip cannot be displayed normally.
More details: Dynamics 365 Business Central: Adding New Notifications

My test code:

pageextension 50112 SalesOrderExt extends "Sales Order"
{
    trigger OnOpenPage()
    var
        PostingDateNotification: Notification;
        PostingDateNotificationLbl: Label 'Posting Date is different from the current date.';
        CheckWorkDate: Label 'Check Work Date?';
    begin
        if Rec."Posting Date" <> Today then begin
            PostingDateNotification.Message(PostingDateNotificationLbl);
            PostingDateNotification.Scope := NotificationScope::LocalScope;
            PostingDateNotification.AddAction(CheckWorkDate, Codeunit::NotificationActionHandler, 'OpenMySettings', 'This is Notification tooltip');
            PostingDateNotification.Send();
        end;
    end;
}

codeunit 50100 NotificationActionHandler
{
    procedure OpenMySettings(PostingDateNofication: Notification);
    begin
        Page.Run(Page::"User Settings");
    end;
}

END

Hope this will help.

Thanks for reading.

ZHU

コメント

Copied title and URL