{"title":"RecordRef.Find([Text]) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/recordref/recordref-find-method/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/recordref/recordref-find-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/recordref/recordref-find-method","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Finds a record in a table based on the values stored in the key fields.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"RecordRef.Find([Text]) Method","slug":"recordreffindtext-method","at":0,"chars":3050},{"level":2,"title":"Syntax","slug":"syntax","at":164,"chars":60},{"level":2,"title":"Parameters","slug":"parameters","at":224,"chars":881},{"level":2,"title":"Return Value","slug":"return-value","at":1105,"chars":238},{"level":2,"title":"Remarks","slug":"remarks","at":1343,"chars":426},{"level":2,"title":"Example","slug":"example","at":1769,"chars":1144},{"level":2,"title":"Related information","slug":"related-information","at":2913,"chars":137}],"text":"# RecordRef.Find([Text]) Method\n> Version: _Available or changed with runtime version 1.0._\nFinds a record in a table based on the values stored in the key fields.\n## Syntax\n```al\n[Ok := ]  RecordRef.Find([Which: Text])\n```\n## Parameters\nRecordRef\nType: recordref-data-type\nAn instance of the recordref-data-type data type.\n*[Optional] Which*\nType: ../text/text-data-type\nSpecifies how to perform the search. The table will be searched until the record is found or there are no more records. Each character in the string can be present only one time. You can use the following characters:\n =  search for a record that equals the key values (default)\n \\>  search for a record that is larger than the key values\n \\<  search for a record that is less than the key values\n +  search for the last record in the table (+ can only be used alone)\n -  search for the first record in the table (- can only be used alone)\nYou can combine the '=', '\\>', and '\\<' characters. If this parameter contains '=', '\\>', or '\\<', then you must assign value to all fields of the current and primary keys before you call FIND.\n## Return Value\n*[Optional] Ok*\nType: ../boolean/boolean-data-type\ntrue 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.\n## Remarks\nFind retrieves the first record that meets the conditions set by the Which parameter and the filters associated with the record. The search path reflects the sort order defined by the current key. If the current key is not the primary key, there is a chance that several records might have the same values in current key fields. If this occurs, the sort order defined by the primary key is used as the search path.\n## Example\nThe following example opens table 18 \\(Customer\\) as a RecordRef variable named CustomerRecref. The value for the field 1 \\(No.\\) is set to a specified record. In this example, the field is set to record 40000. The code uses the Find method to find the record that matches. 40000 in the table. If the record is found, the number, name, address and city of the customer are displayed in message boxes. The values in the fields are retrieved by using the recordref-field-method.\n```al\nvar\n    CustomerRecref: RecordRef;\n    MyFieldRef: FieldRef;\n    varCustomerNo: Code;\n    Text000: Label 'The customer was found.\\\\';\n    Text001: Label 'Customer No. %1 is:\\\\%2';\n    Text002: Label 'Sorry, that customer could not be found.';\nbegin\n    varCustomerNo := '40000';\n    CustomerRecref.Open(18);\n    MyFieldRef := CustomerRecref.Field(1);\n    MyFieldRef.Value := varCustomerNo;\n    if CustomerRecref.Find('=') then begin\n      Message(Text000 + Text001,  CustomerRecref.Field(1), CustomerRecref.Field(2));\n      Message('Address: %1, %2',  CustomerRecref.Field(5),  CustomerRecref.Field(7));\n    end else\n      Message(Text002);\nend;\n```\n## Related information\nrecordref-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}