Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

Pass value from form (header) to subform (lines)

(0) ShareShare
ReportReport
Posted on by 358

I have a Header table;

table 50108 "Production Time Log Header"
{
    DataClassification = ToBeClassified;

    fields
    {
        field(50000; "Entry No"; Integer)
        {
            DataClassification = CustomerContent;
        }
        field(50002; "Production No."; Code[20])
        {
            DataClassification = ToBeClassified;


        }
        field(50003; "Total"; Decimal)
        {
            FieldClass = FlowField;
            CalcFormula = sum ("Production Time Log Lines"."Run Time" where("Production No." = field("Production No.")));
        }
     
    }

    keys
    {
        key(PK; "Entry No")
        {
            Clustered = true;
        }
    }

    var
        myInt: Integer;

    trigger OnInsert()
    var
        recPTLH: Record "Production Time Log Header";
    begin
        Clear(recPTLH);
        IF recPTLH.FindLast() then
            "Entry No" := recPTLH."Entry No" + 1
        else
            "Entry No" := 1;
    end;

}

and a Line table;

table 50113 "Production Time Log Lines"
{
    DataClassification = ToBeClassified;

    fields
    {
        field(50000; "Entry No"; Integer)
        {
            DataClassification = CustomerContent;
        }
        field(50001; "Line No."; Integer)
        {
            DataClassification = CustomerContent;
            Editable = false;
        }
        field(50002; "Production No."; Code[20])
        {
            DataClassification = CustomerContent;
            //   TableRelation = "Production Time Log Header"."Production No." where("Entry No" = field("Entry No"));
            //  ValidateTableRelation = true;

        }
         field(50003; "Process"; Code[20])
        {
            DataClassification = CustomerContent;
            TableRelation = "Work Center";
        }
        field(50012; "Run Time"; Decimal)
        {
            DataClassification = CustomerContent;
        }


    }


    keys
    {
        key(PK; "Entry No", "Line No.")
        {
            Clustered = true;

        }
        key(T; "Run Time")
        {
            MaintainSqlIndex = false;
            MaintainSiftIndex = true;
            SumIndexFields = "Run Time";
        }
    }

    var
        myInt: Integer;

    trigger OnInsert()
    begin

    end;

}

and a Header page;

page 50111 "Production Time Log Card"
{
    PageType = Document;
    ApplicationArea = All;
    UsageCategory = Administration;
    SourceTable = "Production Time Log Header";
    RefreshOnActivate = true;


    layout
    {
        area(Content)
        {
            group(General)
            {
                field("Entry No"; "Entry No")
                {
                    ApplicationArea = All;
                }
                field("Production No."; "Production No.")
                {
                    ApplicationArea = All;
                    TableRelation = "Production Order"."No.";
                }
                field(Total; Total)
                {
                    ApplicationArea = All;
                }
            }
            part(Line; "Production Time Log Subform")
            {

                Visible = true;
                ShowFilter = true;
                UpdatePropagation = Both;
                SubPageLink = "Entry No" = field("Entry No");

            }
        }
    }

 
}

and a Subform;

page 50112 "Production Time Log Subform"
{
    PageType = ListPart;
    ApplicationArea = All;
    UsageCategory = Administration;
    SourceTable = "Production Time Log Lines";
    AutoSplitKey = true;
    DelayedInsert = true;
    MultipleNewLines = true;


    layout
    {
        area(Content)
        {
            repeater(Line)
            {
                field(Process; Process)
                {
                    ApplicationArea = All;

                }
         
                field(Runtime; Runtime)
                {
                    ApplicationArea = All;
                    
                }
            }
        }
    }
    }

}

I am trying to copy the Production Number that gets entered up on the Header to the Lines. So when a new document is created, let's say with Production No. = 100, for the line items that user creates, for every line I would like to save 100 as well. I can get this moved from Header to Line if I keep Production No. as my Primary Key. And my case does not allow that, because for every header with production no 100 I can have multiple Lines posted. Hence I made Entry No as a kind of Document No for my table and increment it by 1 every time. Inshort, how do I get my Production No from header flow to my lines table? Thanks a lot in advance for the help! I have seen 36 and 37 and could not figure it out.

  • KrisMuthy Profile Picture
    100 on at
    RE: Pass value from form (header) to subform (lines)

    create a function as external and in sub page with parameters(par1,par2)

    write code here get the values

    myglobalvalue:=para1

    in Header page call

    call function  with Function (para1,para2)

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at
    RE: Pass value from form (header) to subform (lines)

    This is natively handled by the platform is you set correctly the key. The key for the Production LIne table should be Entry No, Production No, Line No. (3 fields). Set also the SubPageLink accordingly.

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 732

#2
YUN ZHU Profile Picture

YUN ZHU 689 Super User 2025 Season 1

#3
Mansi Soni Profile Picture

Mansi Soni 529

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans