{"title":"Get, Find, and Next methods","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/devenv-get-find-and-next-methods/","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/devenv-get-find-and-next-methods, 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/devenv-get-find-and-next-methods","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":"Learn about the Get, Find, and Next methods for searching records in Business Central.","date":"2025-05-26","meta":{"topic":"concept-article"},"outline":[{"level":2,"title":"Get method","slug":"get-method","at":570,"chars":895},{"level":2,"title":"GetBySystemId method","slug":"getbysystemid-method","at":1465,"chars":727},{"level":2,"title":"Find methods","slug":"find-methods","at":2192,"chars":2123},{"level":2,"title":"Next method","slug":"next-method","at":4315,"chars":478},{"level":2,"title":"Related information","slug":"related-information","at":4793,"chars":91}],"text":"The following methods are used to search for records:\n Get<#get-method>\n Find<#find-methods>\n Next<#find-methods>\nThese methods are some of the most frequently used AL methods. When you search for records, you must know the difference between Get and Find. You should also know how to use Find and Next in conjunction.\n> TIP\n> When using these methods, consider using the partial records methods to improve performance, especially when looping through several records or when table extensions are defined on the table. See Using partial records<devenv-partial-records>.\n## Get method\nThe methods-auto/record/record-get-method retrieves one record based on values of the primary key fields.\nGet has the following syntax.\n```al\n[Ok :=] Record.Get([Value],...)\n```\nFor example, if the No. field is the primary key of the Customer table and if you created a record variable called CustomerRec that has a subtype of Customer, then you can use Get in the following way.\n```al\nCustomerRec.Get('4711');\n```\nThe result is that the record of customer 4711 is retrieved.\nGet produces a runtime error if it fails and the return value isn't checked by the code. In the previous example, the actual code that you write should resemble the following.\n```al\nif CustomerRec.GET('4711') then\n.... // Do some processing.\nelse\n.... // Do some error processing.\n```\nGet searches for a record without changing any current filters. Get always searches through all the records in a table.\n## GetBySystemId method\n> APPLIES TO: Business Central 2019 release wave 2 and later\nThe GetBySystemId(Guid)<methods-auto/record/record-getbysystemid-method> retrieves a record based on the value of its SystemId field.\nGetBySystemId has the following syntax:\n```al\nRecordExists :=   Record.GetBySystemId(SystemId: Guid)\n```\nThe following example gets the record that has the SystemId `5286305A-08A3-E911-8180-001DD8B7338E`:\n```al\nvar\n    Customer: Record Customer;\n    Text000: Label 'Customer was found.';\nbegin\n    If Customer.GetBySystemId('{5286305A-08A3-E911-8180-001DD8B7338E}') then\n    Message(Text000);\nend;\n```\nSimilar to the Get method, GetBySystemId also searches for a record without changing any current filters.\n## Find methods\nThe methods-auto/record/record-find-method locates a record in a table that is based on the values stored in the keys.\nFind has the following syntax.\n```al\nOk := Record.Find([Which])\n```\nThe Which parameter specifies how to perform the search. You can search for values that are greater than, less than, or equal to the key value, or for the first or last record in a table.\nThe important differences between Get and Find are as follows:\n Find uses the current filters.\n Find can look for records where the key value is equal to, greater than, or smaller than the search string.\n Find can find the first or the last record, depending on the sort order defined by the current key.\nWhen you're developing applications in a relational database, there are often one-to-many relationships defined between tables. An example could be the relationship between an Item table, which registers items, and a Sales Line table, which registers the detailed lines from sales orders. One record in the Sales Line table can only be related to one item, but each item can be related to any number of sales line records. You won't want an item record to be deleted as long as there are still open sales orders that include the item. You can use Find to check for open sales orders.\nIf you want to find the first record in a table or set, then use the methods-auto/record/record-findfirst-method. If you want to find the last record in a table or set, then use the methods-auto/record/record-findlast-method.\nThe PickItem procedure of the Item table includes the following code that illustrates using FindFirst.\n```al\nprocedure PickItem(var Item: Record Item): Code[20]\n    var\n        ItemList: Page \"Item List\";\n    begin\n        if Item.FilterGroup = -1 then\n            ItemList.SetTempFilteredItemRec(Item);\n\n        if Item.FindFirst() then;\n        ItemList.SetTableView(Item);\n        ItemList.SetRecord(Item);\n        ItemList.LookupMode := true;\n        if ItemList.RunModal() = ACTION::LookupOK then\n            ItemList.GetRecord(Item)\n        else\n            Clear(Item);\n\n        exit(Item.\"No.\");\n    end;\n```\n## Next method\nThe methods-auto/record/record-next-method is often used with FIND to step through the records of a table.\nNext has the following syntax.\n```al\nSteps := Record.Next([Steps])\n```\nIn the following example, Find is used to go to the first record of the table. Next is used to step through every record, until there are no more. When there are no more records, Next returns a 0 (zero).\n```al\nif (Rec.FindSet) then\nrepeat\n  // process record\nuntil (Rec.Next = 0);\n```\n## Related information\nAL methods<methods-auto/library>\ndevenv-table-system-fields#systemid"}