Options

Link subform to subform

Hi to all,

I want to link a subform to a subform by using the property providerID.
Both subforms are used for data entry.

So i've created the following objects :

Maintable.al
table 50132 "Main Table"
{
    Caption = 'Main';
    fields
    {
        field(2; "No."; Code[20])
        {
            Caption = 'No.';
            DataClassification = CustomerContent;
        }
        field(3; "Description"; Text[100])
        {
            Caption = 'Description';
            DataClassification = CustomerContent;
        }
        field(4; "Description 2"; Text[50])
        {
            Caption = 'Description 2';
            DataClassification = CustomerContent;
        }
    }
    keys
    {
        key(Key1; "No.")
        {
            Clustered = true;
        }
    }
}

Subtable1.al
table 50134 "Sub 1 Table"
{
    Caption = 'Sub1';
    fields
    {
        field(2; "Document No."; Code[20])
        {
            DataClassification = CustomerContent;
            Caption = 'Document No.';
        }
        field(3; "Line No."; Integer)
        {
            DataClassification = CustomerContent;
            Caption = 'Line No.';
        }
        field(22; Description; Text[100])
        {
            DataClassification = CustomerContent;
            Caption = 'Description';
        }
        field(23; "Description 2"; Text[100])
        {
            DataClassification = CustomerContent;
            Caption = 'Description';
        }
    }

    keys
    {
        key(Key1; "Document No.", "Line No.")
        {
            Clustered = true;
        }

    }
}

Subtable2.al
table 50137 "Sub 2 Table"
{
    Caption = 'SUB2';
    
    fields
    {
        field(2; "Document No."; Code[20])
        {
            Caption = 'Document No.';
        }
        field(3; "Document Line No."; Integer)
        {
            Caption = 'Document Line No.';
        }
        field(4; "Line No."; Integer)
        {
            Caption = 'Line No.';
        }

        field(70; Description; Text[100])
        {
            DataClassification = CustomerContent;
            Caption = 'Description';
        }
        field(71; "Description 2"; Text[100])
        {
            DataClassification = CustomerContent;
            Caption = 'Description';
        }
    }

    keys
    {
        key(Key1; "Document No.", "Document Line No.", "Line No.")
        {
            Clustered = true;
        }
    }
}

MainPage.al
page 50133 "Main Page"
{
    Caption = 'Main PAge';
    PageType = Document;
    RefreshOnActivate = true;
    SourceTable = "Main Table";

    layout
    {
        area(content)
        {
            group(General)
            {
                Caption = 'General';
                field("No."; "No.")
                {
                    ApplicationArea = All;
                }
                field("Description"; "Description")
                {
                    ApplicationArea = All;
                    ShowMandatory = true;
                }
                field("Description 2"; "Description 2")
                {
                    ApplicationArea = All;
                    ShowMandatory = true;
                }
            }
            part(Sub1Page; "Sub 1 Page")
            {
                ApplicationArea = All;
                SubPageLink = "Document No." = FIELD("No.");
                UpdatePropagation = Both;
            }
            part(Sub2Page; "Sub 2 Page")
            {
                                ApplicationArea = All;
                Provider = Sub1Page;
                SubPageLink = "Document No." = FIELD("Document No."),
                               "Document Line No." = FIELD("Line No.");
                UpdatePropagation = Both;
            }           
        }
    }
}

Sub1Page.al
page 50136 "Sub 1 Page"
{
    AutoSplitKey = true;
    Caption = 'Lines';
    //DelayedInsert = true;
    LinksAllowed = false;
    MultipleNewLines = true;
    PageType = ListPart;
    SourceTable = "Sub 1 Table";

    layout
    {
        area(content)
        {
            repeater(Control1)
            {
                ShowCaption = false;
                field("Document No."; "Document No.")
                {
                    ApplicationArea = All;
                }
                field("Line No."; "Line No.")
                {
                    ApplicationArea = All;
                }
                field(Description; Description)
                {
                    ApplicationArea = All;
                }
                field("Description 2"; "Description 2")
                {
                    ApplicationArea = All;
                }
            }
        }
    }
}

Sub2Page.al
page 50139 "Sub 2 Page"
{
    AutoSplitKey = true;
    Caption = 'SubPage2';
    DelayedInsert = true;
    LinksAllowed = false;
    MultipleNewLines = true;
    PageType = ListPart;
    SourceTable = "Sub 2 Table";

    layout
    {
        area(content)
        {
            repeater(Control1)
            {
                ShowCaption = false;

                field("Document No."; "Document No.")
                {
                    ApplicationArea = All;
                }
                field("Line No."; "Line No.")
                {
                    ApplicationArea = All;
                }
                field("document Line No."; "document Line No.")
                {
                    ApplicationArea = All;
                }
                field(Description; Description)
                {
                    ApplicationArea = All;
                }
                field("Description 2"; "Description 2")
                {
                    ApplicationArea = All;
                }
            }
        }
    }
}

I have two major problems. When the delayedinsert = false on the first subpage (as in the code above), i receive a page notification

mf7jcc0b14iv.png

If i set the property delayedinsert = true on the first subpage, and the focus is set to the second subform, the line no. is not yet initialized, so i lose the link between those two tables

g0rfok7c3mwa.png

Hopefully someone has a solution for this.

Thanks in advance

Kind regards
Sign In or Register to comment.