RE: unit price missing on sales order and and how to make boolean field active inavtive according to unit price
Hi Salba Z.K ,
can you please check if the new sales price is enabled by going to Feature management? and then please replace your code as per below
Below is suitable event, but condition I put might be wrong please correct them accordingly.
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Sales Line - Price", 'OnAfterSetPrice', '', false, false)]
local procedure OnAfterSetPrice(var SalesLine: Record "Sales Line"; PriceListLine: Record "Price List Line"; AmountType: Enum "Price Amount Type")
var
salesHeader: record "Sales Header";
begin
if not salesHeader.get(SalesLine."Document Type", SalesLine."Document No.") then
exit;
if PriceListLine."Unit Price" > SalesLine."Unit Price" then
salesHeader."Min. Price Change Hold" := true;
if PriceListLine."Unit Price" < SalesLine."Unit Price" then
salesHeader."Min. Price Change Hold" := false;
salesHeader.Modify();