Dynamics 365 Business Central: Double Click trigger on the list page???

Dynamics 365 Business Central

Hi, Readers.
Today, I would like to continue talking about a very interesting topic, Double Click trigger in Business Central.

Let’s watch a test video first: Double click the Payment Term to display a message.

How is this done?
As we all know, there is no trigger for Double Click in Business Central and NAV.

Does this require a “non-BC” way, such as add-in or JavaScript?
No, it’s actually easier than one might think, but there are some limitations.

In Business Central, we don’t have double click trigger, but has double click behavior.
For example, on the Item List (31, List) page, Sales Order List (9305, List) page, etc.

Why? Because the CardPageID property is set on these List Pages. Double-clicking will open the set Card page by default.
CardPageId Property: Sets the card page that is associated with items in the current list page.

We can use this behavior😁.

Let me take Payment Terms as an example.

List Page:

page 50001 "New Payment Terms"
{
    ApplicationArea = All;
    Caption = 'New Payment Terms';
    PageType = List;
    CardPageId = "New Payment Terms Card";
    SourceTable = "Payment Terms";
    UsageCategory = Lists;

    layout
    {
        area(content)
        {
            repeater(General)
            {
                field("Code"; Rec."Code")
                {
                    ToolTip = 'Specifies a code to identify this set of payment terms.';
                    ApplicationArea = All;
                }
                field("Due Date Calculation"; Rec."Due Date Calculation")
                {
                    ToolTip = 'Specifies a formula that determines how to calculate the due date, for example, when you create an invoice.';
                    ApplicationArea = All;
                }
                field("Discount Date Calculation"; Rec."Discount Date Calculation")
                {
                    ToolTip = 'Specifies the date formula if the payment terms include a possible payment discount.';
                    ApplicationArea = All;
                }
                field(Description; Rec.Description)
                {
                    ToolTip = 'Specifies an explanation of the payment terms.';
                    ApplicationArea = All;
                }
            }
        }
    }
}

Card Page: You can add what you want to execute before Error(”). And since this page does not need to be displayed, no fields need to be added.

page 50002 "New Payment Terms Card"
{
    Caption = 'New Payment Terms Card';
    PageType = Card;
    SourceTable = "Payment Terms";

    trigger OnOpenPage()
    begin
        Message('This message is displayed after double-clicking ''%1''.', Rec.Code);
        Error('');
    end;
}

This mainly utilizes the following feature of OnOpenPage (Page) Trigger.

If an error occurs in the trigger execution, then the page closes.

In fact, you can also use OnInit (Page) Trigger, but there is no way to get the value of Rec in this trigger. So personally do not recommend.

Isn’t it fun, give it a try!!!😁

Note: We can’t change the behavior of the standard list page with this method.

The property ‘CardPageId’ cannot be customized. AL (AL0246)

END

Hope this will help.

Thanks for reading.

ZHU

コメント

タイトルとURLをコピーしました