Skip to main content

Notifications

Business Central forum
Answered

How to enable click and navigate on a Page control

Posted on by 2,983

I have created a table, with a complex table relation in a field:

field(1; InvoiceNo; Code[20])
        {
            Caption = 'InvoiceNo';
            DataClassification = ToBeClassified;
            TableRelation =
        if ("Document Type" = const(Invoice)) "Sales Invoice Header"."No."
            else
            if ("Document Type" = const("Credit Memo")) "Sales Cr.Memo Header"."No.";
        }
Then I created a read only List Page, with all elements of this table. The relation is working correctly, but when I click or double click the InvoiceNo field, It doesn't open the Posted Sales Invoice Card or the Posted Cr. memo Card.
I can only open the page using the link in the lookup
any ideas on how to enable opening on a click or double click?
pastedimage1632741555250v1.png
Categories:
  • Ghetz Profile Picture
    Ghetz 2,983 on at
    RE: How to enable click and navigate on a Page control

    Actually I was expecting a standard way of doing it without code, just like when you click the order No. on the Sales Order list, the order card opens up. I guess this only works when there is a ListPage - CardPage relation.

  • Suggested answer
    JAngle Profile Picture
    JAngle 33,141 on at
    RE: How to enable click and navigate on a Page control

    Different scenario but similar requirement. I have a field on the G/L entries to show me the source record name of the posting - so for customer it's the customer name etc. I have a drilldown set on the calculated field and it opens the card page directly based on whichever record it is. Here is some sample code. Might help you.

    My field to show the name of the record relating to the G/L entry:

    addafter("Source Code")
            {
                field("Source Name"; SourceName)
                {
                    ApplicationArea = All;
                    Caption = 'Source Name';
                    trigger OnDrillDown()
                    var
                    DataDrillDown: Codeunit "Data Tasks";
                    begin
                        DataDrillDown.SourceNameDrillDown(Rec."Source Type",Rec."Source No.");
                    end;
                }
            }

    Doesn't include all the code but it effectively just loops through depending on what the drilldown record relates to and calls a page opening function

    procedure SourceNameDrillDown(var RefType: Enum "Gen. Journal Source Type"; var RefCode: Code[20])
        var
            DataRefType: Enum "Gen. Journal Source Type";
            Cust: Record Customer;
            Vend: Record Vendor;
            Bank: Record "Bank Account";
            Empl: Record Employee;
            FA: Record "Fixed Asset";
        begin
            DataRefType := RefType;
    
            case DataRefType of
                DataRefType::" ":
                    Page.RunModal(0);
                DataRefType::"Bank Account":
                    begin
                        Bank.Init();
                        if Bank.Get(RefCode) then
                            GetBankAccountPage(Bank);
                    end;
                DataRefType::Customer:
                    begin
                        Cust.Init();
                        if Cust.get(RefCode) then
                            GetCustomerPage(Cust);
                    end;
                end;
            end;

    page opening function example. So you could create two of these - one for the sales invoice and one for the sales credit memo:

    local procedure GetCustomerPage(var Customer: Record "Customer")
        var
            CustLookup: Page "Customer Card";
        begin
            CustLookup.Editable := false;
            CustLookup.SetTableView(Customer);
            CustLookup.RunModal();
        end;

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 9th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,186 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 227,996 Super User 2024 Season 2

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans