上QQ阅读APP看书,第一时间看更新
How to do it...
- Open your AL project folder in Visual Studio Code.
- In Visual Studio Code's Explorer pane, right-click and create a new file named Customers With Television Shows Filter Token.al. In the Editor tab, create a new codeunit object, and then add the following code:
codeunit 50103 "Customers With Shows Filter"
{
[EventSubscriber(ObjectType::Codeunit,
Codeunit::TextManagement, 'OnAfterMakeTextFilter',
'', true, true)]
local procedure OnAfterMakeTextFilter(var Position: Integer;
var TextFilterText: Text)
var
Customer: Record Customer;
CustomerTelevisionShows: Record "Customer Television Show";
CustWithShowsTokenTxt: Label 'CUSTWITHSHOWS';
MaxCount: Integer;
begin
if StrPos(UpperCase(CustWithShowsTokenTxt),
UpperCase(TextFilterText)) = 0 then
exit;
MaxCount := 2000;
TextFilterText := '';
if Customer.FindSet() then begin
repeat
CustomerTelevisionShows.SetRange("Customer No.",
Customer."No.");
if not CustomerTelevisionShows.IsEmpty() then begin
MaxCount -= 1;
if TextFilterText <> '' then
TextFilterText += '|';
TextFilterText += Customer."No.";
end;
until (Customer.Next() = 0) or (MaxCount <= 0);
end;
end;
}
- Now, let's test it! Press F5 to build and publish your application. Navigate to the Customers list page and click the icon to show the filter pane. Enter a filter value of %CustWithShows into the No. field and press Tab. Note the value that you enter is not case-sensitive:
The list should get filtered down to only show the customers that have television shows defined. If your list is empty, then release the filter, enter some television shows for a customer or two, and try the filter again.