FIND Function (Record)

Finds a record in a C/SIDE table based on the values stored in keys.

Ok := Record.FIND([Which])


  • Record
    Type: Record

    On input, Record identifies the record that you want to find. On output, the following possibilities exist:

    • If the record was found, then the record is returned in the Record parameter and any FlowFields in the record are set to zero. You must update the FlowFields using the CALCFIELDS Function (Record).

    • If the record was not found and if you omitted the return value, a run-time error occurs.

  • Which
    Type: Text or code

    Specifies how to perform the search. The table is searched until either a record is found or there are no more records. Each character in this string can be present only once. You can combine the '=', '<', and '>' characters. You can use the following characters:

    • =  to search for a record that equals the key values (default)

    • >  to search for a record that is larger than the key values

    • <  to search for a record that is less than the key values

    • +  to search for the last record in the table (+ can only be used alone)

    • -   to search for the first record in the table (- can only be used alone)

    If this parameter contains '=', '>' or '<', then you must assign value to all fields of the current and primary keys before you call FIND.

Property Value/Return Value

Type: Boolean

true if the record was found; otherwise, false.

If you omit this optional return value and if the record cannot be found, a run-time error occurs. If you include a return value, you must handle any errors.


FIND retrieves the first record that meets the conditions set by Which and the filters associated with Record. The search path reflects the sort order defined by the current key. If the current key is not the primary key, several records might have the same values in current key fields. If this happens, the sort order defined by the primary key as the search path is used.

For more information about the performance differences between using FINDSET and FIND('-'), see C/AL Database Functions and Performance on SQL Server.


This example requires that you create the following variables an text constants in the C/AL Globals window.

Variable name Datatype Subtype







Text constant ENU value


The customer was found.\


Customer No. %1 is:\%2


Sorry, that customer could not be found.

MyDialog.OPEN('Search for customer number...\'
  + '#1##################');
MyDialog.INPUT(1, CustomerRec."No.");
IF CustomerRec.FIND THEN
  MESSAGE(Text000 + Text001, CustomerRec."No.", CustomerRec.Name)

First, you are prompted to enter a customer number to search for.

Search for customer number…

If the number you enter does not exist, the following message is displayed:

Sorry, that customer could not be found.

If the number is found in the Customer table, a message similar to the following is displayed:

The customer was found.

Customer number 01445544 is:

Progressive Home Furnishings

See Also


Record Data Type