Hello Experts,
I have been assigned a task that prevent Items at the level of SO Lines to appears (filter them) according to the (Item category Code) for more explanation I have made a table
table 60150 "Xee Customer/Category Prevent"
{
Caption = 'Customer / Category Prevention';
DataClassification = ToBeClassified;
fields
{
field(1; "Item Categ. Code"; Code[20])
{
Caption = 'Item Categ. Code';
DataClassification = ToBeClassified;
TableRelation = "Item Category";
}
field(2; Description; Text[100])
{
Caption = 'Description';
DataClassification = ToBeClassified;
}
field(3; "Customer No."; Code[20])
{
Caption = 'Customer No.';
DataClassification = ToBeClassified;
}
field(4; "Line No."; Integer)
{
Caption = 'Line No.';
DataClassification = ToBeClassified;
}
}
and here I can fill what category is prevented to a certain customer.
The Level I am stuck on it at the moment is that I am getting the banned Category on the "Sales Order Subform" page 46
trigger OnAfterGetRecord()
var
SalesHeader: Record "Sales Header";
Customer: Record Customer;
PreventedBrands: Record "Xee Customer/Category Prevent";
i: Integer;
begin
i := 0 ;
if BannedCategoryy.Count > 0 then begin
for i := BannedCategoryy.Count() downto 1 do
BannedCategoryy.RemoveAt(i);
end;
if SalesHeader.get(Rec."Document Type", Rec."Document No.") then;
if Customer.get(SalesHeader."Sell-to Customer No.") then;
PreventedBrands.SetRange("Customer No.", Customer."No.");
if PreventedBrands.FindFirst() then
repeat
BannedCategoryy.Add(PreventedBrands."Item Categ. Code");
until PreventedBrands.Next() = 0;
end;
But I haven't found a way to make a filter that the user when he press on the (No.) or (description) fields the dropdown list will be already filtered.