Monday, March 2, 2026

Business Central AL - Refer to a field without using a dependency

 local procedure SetProgrammaticPromoLine(var SalesLine: Record "Sales Line"; Value: Boolean)

    var

        RecRef: RecordRef;

        FldRef: FieldRef;

    begin

        // Dynamically set "DVN Programmatic Promo Line" field (ID 58565) from Davyn Promotions extension

        // This allows compatibility without requiring a hard dependency

        RecRef.GetTable(SalesLine);

        if RecRef.FieldExist(58565) then begin

            FldRef := RecRef.Field(58565);

            FldRef.Value := Value;

            RecRef.SetTable(SalesLine);

        end;

    end;

No comments:

Post a Comment