Auto Populate Header Field to Line table

Hi Guys

I have two tables commissionHeader and Commisionlines with a relationship just like Sales Header and Line, I have agent no. field on the header and when it is selected i wanted it also to get populated on line field and tried to copy the function from Sales Header.

TESTFIELD("Document No.");
IF ("Document Type" <> SalesHeader."Document Type") OR ("Document No." <> SalesHeader."No.") THEN BEGIN
SalesHeader.GET("Document Type","Document No.");
IF SalesHeader."Currency Code" = '' THEN
Currency.InitRoundingPrecision
ELSE BEGIN
SalesHeader.TESTFIELD("Currency Factor");
Currency.GET(SalesHeader."Currency Code");
Currency.TESTFIELD("Amount Rounding Precision");
END;
END;

Tried to Modify it like below

TESTFIELD("No.");
IF ("No." <> CommisionDocumentHeader."Document No.") THEN BEGIN
CommisionDocumentHeader.GET(CommisionDocumentHeader."Document No.");
END;

Then Called the function on pk field on validate, then tried to assign header field to the line but nothing happened

GetCommissionHeader;
"Agent No.":= CommisionDocumentHeader."Agent No.";

Appreciate for your help in advance

Parents
  • I think you selected the wrong example. If I understood your description correctly you need to see the UpdateSalesLines function like an example.

    if you need to take data from the header in line you can check your code or InitHeaderDefaults.

Reply Children
Related
Recommended