0

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?

NickSO
  • 33
  • 2
  • 6

2 Answers2

1

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

https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/record/record-mark-method

https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/record/record-markedonly-method

Jonathan Bravetti
  • 2,228
  • 2
  • 15
  • 29
0

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;
kaspermoerch
  • 16,127
  • 4
  • 44
  • 67