Reputation: 103
In an AL Extension CodeUnit, how do you iterate through the records that a user has selected / marked / ticked on a list page using the 'Select More' functionality? For instance, is there an IsMarked / IsSelected / IsTicked property in a data-type somewhere? Or, can you pass in the already drilled-down list to the codeunit?
Upvotes: 0
Views: 9194
Reputation: 16570
To pass the selection on a given page to a codeunit or procedure you use the SetSelectionFilter
function. This function copies the current selection to another record variable which you can then iterate over or pass as an argument.
In the example below it is assumed that the page in question has the Sales Line
table as its source:
local procedure CallMyCodeunit();
var
SalesLine: Record "Sales Line";
MyCodeunit: Codeunit "My Codeunit";
begin
CurrPage.SetSelectionFilter(SalesLine);
MyCodeunit.DoSomething(SalesLine);
end;
Upvotes: 0
Reputation: 2238
There are several ways to do it.
You have the methods Mark
and MarkedOnly
.
With Mark you can Mark
records and MarkedOnly
you can see only marked records.
Once they are marked you can go through them and assign them to a temporary table, Then you can pass this table to the codeunit method. Or you can pass the tabla like VAR parameter to the codeunit method and then do the loop.
Here definitios of Mark and MarkedOnly
Upvotes: 2