Trying to add a procedure that will determine if the Location Code field on the Sales Order Subform should show as Mandatory based on the Sales Line Item and Item.Type. Works fine for the Item being entered, but then also updates the setting for ALL items in the Subform based on the current record. Below is the procedure that I am calling from the OnAfterValidate trigger of the No. field in the Subform. I only want it to change the boolean value on the line being modified.
What am I missing? Is there a way to do that? Visual below. Before the last line item was entered, the 2nd-4th lines did not show the asterisk, the 5th line should have the fields mandatory, when the Item was entered, all the lines changed.

modify("No.")
{
trigger OnAfterValidate()
begin
ShowMandatoryResults()
end;
}
modify("Location Code")
{
ShowMandatory = ShowMandatoryValue;
}
procedure ShowMandatoryResults()
begin
SalesLine.SetRange("Document Type", SalesDocumentType::Order);
SalesLine.SetRange("Document No.", Rec."Document No.");
SalesLine.SetRange("Line No.", Rec."Line No.");
if SalesLine.FindSet() then begin
If SalesLine.Type <> SalesLineType::Item then
exit
else begin
Item.SetRange("No.", SalesLine."No.");
Item.SetRange(Type, ItemType::Inventory);
if Item.FindSet() then
ShowMandatoryValue := true
else
ShowMandatoryValue := false;
end;
end;
end;
var
SalesLine: Record "Sales Line";
Item: Record Item;
SalesLineType: Enum "Sales Line Type";
SalesDocumentType: Enum "Sales Document Type";
ItemType: Enum "Item Type";
ShowMandatoryValue: Boolean;