Record.FindSet([Boolean]) Method

Version: Available or changed with runtime version 1.0.

Finds a set of records in a table based on the current key and filter.


[Ok := ]  Record.FindSet([ForUpdate: Boolean])


 Type: Record
An instance of the Record data type.

[Optional] ForUpdate
 Type: Boolean
Set this parameter to true if you want to modify any records in the set; otherwise, set the parameter to false. If you set this parameter to true, then the records will be read with Updlock. If you set this parameter to false, then you can still modify the records in the set, but these updates will not be performed optimally. The default value is false.

Return Value

[Optional] Ok
 Type: Boolean
true if the operation was successful; otherwise false. If you omit this optional return value and the operation does not execute successfully, a runtime error will occur.


You should use this method only when you explicitly want to loop through a recordset. You should only use this method in combination with repeat..until.

The difference between Find() and FindSet is that Find uses paging and the method only requests N rows in the first request, and then if you need more rows, it'll submit a new SQL request. The FindSet method will request all rows at once.

The difference between FindSet(false) and FindSet(true) is that FindSet(true) will do a LockTable() before finding rows, which is an advantage if you plan to update all the rows you are finding.

This method works the same way as the FindSet Method (RecordRef).


The following examples are meant for illustration purposes of the usage of the FindSet method only and are not meant to illustrate best practices.

Example 1

This example shows how to use the FindSet method to loop through a set without updating it, only running a validation on each record. This example requires a VATRegistrationValidation method, which is not included in this example:

    procedure Example_1()
        CompanyInformation: Record "Company Information";
        Customer: Record Customer;
        Customer.SetFilter("Country/Region Code", '<>%1', CompanyInformation."Country/Region Code");
        if Customer.FindSet(false) then
            until Customer.Next() = 0;

Example 2

This example shows how to use the FindSet method to loop through a set and update a field.

    procedure Example_2()
        Customer: Record Customer;
        SalesHeader: Record "Sales Header";
        SalesHeader.SetRange("Sell-to Customer No.", Customer."No.");
        SalesHeader.SetFilter("Bill-to Customer No.", '<>%1', Customer."No.");
        if SalesHeader.FindSet(true) then
                SalesHeader."Ship-to contact" := SalesHeader."Bill-to Contact";
            until SalesHeader.Next() = 0;

See Also

Record Data Type
Getting Started with AL
Developing Extensions