Options

Using Temp Table for ListPart page source table

samantha73samantha73 Member Posts: 96
Hi All
I'm still trying to get tableType = Temporary work in certain scenarios.
Has anyone used a temp table on a listpart page or factbox?
Created a list part page on sales order to show subtotals and the source table is marked as temp table, but then using temp table no data displayed (BC SaaS 19v)

Table
table 60114 SubTotalSales
{
    DataClassification = ToBeClassified;
    Caption = 'sub';
    TableType = Temporary;
    fields
    {
        field(60001; DocNum; Code[50])
        {
            DataClassification = ToBeClassified;
            Caption = 'Code';
        }
        field(60002; Group1; Integer)
        {
            DataClassification = ToBeClassified;
            Caption = 'Code';
        }
        field(60000; Category; Text[200])
        {
            Caption = 'Category;';
        }
        field(60004; SubTotal; Decimal)
        {
            Caption = 'SubTotal';
            Editable = false;
        }
    }
    keys
    {
        key(PK; DocNum, Group1)
        {
            Clustered = true;
        }
    }[img]https://us.v-cdn.net/5022383/uploads/editor/c5/k2mhqygzf5cw.png[/img]

ListPart page - function called from sales order page action
page 50105 SalesSubTotalsPart
{
    PageType = ListPart;
    ApplicationArea = All;
    Editable = false;
    UsageCategory = Administration;
    SourceTable = SubTotalSales;
    DeleteAllowed = false;
    InsertAllowed = false;
    layout
    {
        area(content)
        {
            repeater(Control2)

            {
                Caption = 'Sub';
                ShowCaption = false;
                field(Doc; Rec.DocNum)
                {
                    ApplicationArea = All;
                    Width = 10;

                }
                field(Group1; Rec.Group1)
                {
                    ApplicationArea = all;
                }

                field(Cat; Rec.Category)
                {
                    ApplicationArea = all;
                    Width = 10;
                }

                field(SubTotal; Rec.SubTotal)
                {
                    ApplicationArea = all;
                }

            }
        }
    }

    procedure CalculateSubTotalProc(Var DocNum: Code[50])//called from sales order action

    var
        SalesLine: Record "Sales Line";
      
        TotalAmount: Decimal;

    begin
        Rec.DeleteAll();
        TotalAmount := 0;
        begin//insert
            SalesLine.Reset();

            SalesLine.SetRange("Document Type", SalesLine."Document Type"::Quote);
            SalesLine.SetRange("Document No.", DocNum);
            SalesLine.SetRange(Type, SalesLine.Type::" ");
            if SalesLine.FindSet() then
                Rec.Init();
            repeat
                Rec.DocNum := SalesLine."Document No.";
                Rec.Group1 := SalesLine.Group1;
                Rec.Category := SalesLine.Description;
                Rec.Insert();
            until SalesLine.Next() = 0;
        end;
        begin
            Rec.Reset();
            if Rec.FindSet() then
                repeat
                    Clear(TotalAmount);//
                    SalesLine.Reset();
                    SalesLine.SetRange("Document Type", SalesLine."Document Type"::Quote);
                    SalesLine.SetRange("Document No.", Rec.DocNum);
                    SalesLine.SetRange(Group1, Rec.Group1);
                    if SalesLine.FindSet() then
                        repeat
                            TotalAmount := TotalAmount + SalesLine."Line Amount";

                        until SalesLine.Next() = 0;
                    Rec.SubTotal := TotalAmount;
                    Rec.Modify();

                until Rec.Next() = 0;
        end;

    end;


Answers

  • Options
    yzhumsyzhums Member Posts: 10
    Hi, I think you can refer to Item Attributes Factbox (9110, ListPart).
    jeejkqwz3aqk.png
  • Options
    samantha73samantha73 Member Posts: 96
    Checked the item attributes but the table construct is different as the source table itself is not a temp table. Temporary property is only defined on the page
    page 9110 "Item Attributes Factbox"
    {
        Caption = 'Item Attributes';
        DeleteAllowed = false;
        InsertAllowed = false;
        ModifyAllowed = false;
        PageType = ListPart;
        RefreshOnActivate = true;
        SourceTable = "Item Attribute Value";
        SourceTableTemporary = true;
    
        layout
        {
    
  • Options
    AgannaloAgannalo Member Posts: 12
    First of all generate data on subpage. On Sales Order Header Card/List add code OnAfterGetRecord. This code should call function from your subpage. Of course use variable that suits you best.:
    CurrPage.PagePart.Page.SetTempSourceData(Rec);
    
    Here in subpage assign what you wish to preview. For example
    procedure SetTempSourceData(SalesHeader: Record "Sales Header")
        var
            SalesLine: Record "Sales Line";
        begin
            SalesLine.SetRange("Document Type", SalesHeader."Document Type");
            SalesLine.SetRange("Document No.", SalesHeader."No.");
            if SalesLine.FindSet() then begin
                repeat
                    Rec := SalesLine;
                    Rec.Insert();
                until SalesLine.Next() = 0;
            end;
            CurrPage.Update();
        end;
    
Sign In or Register to comment.