Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

How to update factbox using code in bc15

(0) ShareShare
ReportReport
Posted on by 40

Hi,

I want to update factbox through code from the page. the factbox is not getting updated with filtered values.I'm not sure what is wrong with the below code

The page code looks like below

page 50010 "ItemLedgerEntrie"
{

    CaptionML = ENU = 'Item Ledger Entries',
                DEU = 'Artikelposten';
    PageType = List;
    editable = false;
    SourceTable = "Item Ledger Entry";

    //PromotedActionCategoriesML = ENU = 'New,Process,Report,Manage,SalesInvoice', DEU = 'Neu,Prozess,Bericht,Verwalten,VK-Rechnung';

    layout
    {
        area(content)
        {
            repeater(General)
            {
                field("Document Date"; Rec."Document Date")
                {
                    ToolTip = 'Specifies the value of the Document Date field';
                    ApplicationArea = All;
                }
                field("Document No."; Rec."Document No.")
                {
                    ToolTip = 'Specifies the value of the Document No. field';
                    ApplicationArea = All;
                    trigger OnDrillDown()
                    var
                        SalesShipmentHeader: Record "Sales Shipment Header";
                        PostedSalesShipment: Page "Posted Sales Shipment";
                    begin
                        SalesShipmentHeader.RESET;
                        SalesShipmentHeader.Get(rec."Document No.");
                        CLEAR(PostedSalesShipment);
                        PostedSalesShipment.SETRECORD(SalesShipmentHeader);
                        PostedSalesShipment.SETTABLEVIEW(SalesShipmentHeader);
                        PostedSalesShipment.LOOKUPMODE(TRUE);
                        PostedSalesShipment.EDITABLE(TRUE);
                        IF PostedSalesShipment.RUNMODAL = ACTION::OK THEN BEGIN
                            PostedSalesShipment.GETRECORD(SalesShipmentHeader);
                        END;
                    end;

                }

            }
        }
        area(factboxes)
        {
            part(PostedsalesInvoiceFB; "PostedsalesInvoiceFB")
            {
                ApplicationArea = all;
            }
        }
    }



    trigger OnAfterGetCurrRecord()
    var
        TempSalesInvLine: Record "Sales Invoice Line" temporary;
    begin
        clear(TempSalesInvLine);
        GetSalesInvLines(TempSalesInvLine);
        IF not TempSalesInvLine.IsEmpty THEN
            if TempSalesInvLine.FindFirst() then begin
                CurrPage.PostedsalesInvoiceFB.Page.UpdateRecord(TempSalesInvLine);
            end;
        CurrPage.UPDATE(true);
    end;
factbox:
page 50025 "PostedsalesInvoiceFB"
{
    Caption = 'Invoiced Items';
    PageType = CardPart;
    SourceTable = "Sales Invoice Line";
    SourceTableTemporary = true;
    InsertAllowed = false;
    Editable = false;
    DeleteAllowed = false;

    layout
    {
        area(content)
        {

            field("Document No."; "Document No.")
            {
                ApplicationArea = all;
                trigger OnLookup(var myText: Text)boolean
                var
                    SalesInvHeader: Record "Sales Invoice Header";
                    PostedSalesInv: Page "Posted Sales Invoice";
                begin
                    if SalesInvHeader.get(rec."Document No."then begin
                        CLEAR(PostedSalesInv);
                        PostedSalesInv.SETRECORD(SalesInvHeader);
                        PostedSalesInv.SETTABLEVIEW(SalesInvHeader);
                        PostedSalesInv.LOOKUPMODE(TRUE);
                        PostedSalesInv.EDITABLE(TRUE);
                        IF PostedSalesInv.RUNMODAL = ACTION::OK THEN BEGIN
                            PostedSalesInv.GETRECORD(SalesInvHeader);
                        END;
                    end
                end;

            }
            field(No; "No.")
            {
                ApplicationArea = All;
            }
            field(Description; Description)
            {
                ApplicationArea = All;
            }
            field(Amount; Amount)
            {
                ApplicationArea = All;
            }
            field("Order No."; "Order No.")
            {
                ApplicationArea = all;
            }
        }
    }

    procedure UpdateRecord(Var TempSalesInvLine: record "Sales Invoice Line" temporary)
    var
        myInt: Integer;
    begin
        rec.Reset();
        // rec.Delete();
        Rec.Copy(TempSalesInvLine, true);
        CurrPage.Update();

    end;
Thanks in advance.
  • Suggested answer
    Andy Sather Profile Picture
    Andy Sather on at
    RE: How to update factbox using code in bc15

    Hello Nancy - We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist.  If you need assistance with debugging or coding I would recommend discussing this on one of our communities.

    www.yammer.com/dynamicsnavdev

    dynamicsuser.net/.../developers

    I will open this up to the community in case they have something to add.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,735 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,466 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans