Linking Card Page to a Part Page - Muhammad-Ali-Mughal/Microsoft-Dynamics-BC-AL-Extension GitHub Wiki

How to link a Card Page to a Part Page?

You can easily create and place a part page into a card page by defining it inside area and providing the name of part page, but there is still issue. What happens when you try to insert a new record in the card page? The whole card page will be updated while part page containing the same old record. So, how do we create a link between them so both of them can propagate?

The solution is very simple and to the point. Microsoft has provided a bunch of useful properties, which covers you around, for almost every functionality required to implement business logic.

Solution:

part(Content_Listpart; "Cronus Course ListPart")
            {
                Caption = 'ListPart';
                ApplicationArea = All;
                SubPageLink = "Doc No." = field(Code);
                UpdatePropagation = Both;            
             }

Here, two main properties are used:

SubPageLink

This creates a link between both of the pages. You have to provide the fields (which are keys) through which you want to link both of the pages. In this scenario, "Doc No." is the Primary key field of the Card page table in which part in placed and it is then linked to the field Code of the ListPart page table. In this way, "Doc No." field will get corresponding Code field data. There is another point to be noted that Code field will have the same value as of "Doc No." field because both are linked together.

UpdatePropagation

This property defines that both of these pages will propagate with each other. If new record is inserted, both of these table initialize and save the new record correspondingly and vice versa in case of deletion.

Conditional Editing of Part Page

Microsoft has also provided conditional apply of properties on objects. Following is the solution for this:

part(Content_Listpart; "Cronus Course ListPart")
            {
                Caption = 'ListPart';
                ApplicationArea = All;
                SubPageLink = "Doc No." = field(Code);
                UpdatePropagation = Both;
                Editable = Rec.Code <> '';
            }

Here, the line "Editable = Rec.Code <> '';" means that if current record is having Code field not equal to empty string then Editable is true, otherwise, false.