{"title":"Page.SetRecord(var Record) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/page/page-setrecord-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/page/page-setrecord-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/page/page-setrecord-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":"Sets the current record for the page.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"Page.SetRecord(var Record) Method","slug":"pagesetrecordvar-record-method","at":0,"chars":1411},{"level":2,"title":"Syntax","slug":"syntax","at":134,"chars":56},{"level":2,"title":"Parameters","slug":"parameters","at":190,"chars":226},{"level":2,"title":"Remarks","slug":"remarks","at":416,"chars":94},{"level":2,"title":"Example","slug":"example","at":510,"chars":769},{"level":2,"title":"Related information","slug":"related-information","at":1279,"chars":132}],"text":"# Page.SetRecord(var Record) Method\n> Version: _Available or changed with runtime version 1.0._\nSets the current record for the page.\n## Syntax\n```al\n Page.SetRecord(var Record: Record)\n```\n## Parameters\nPage\nType: page-data-type\nAn instance of the page-data-type data type.\nRecord\nType: ../record/record-data-type\nThe record to set as the current record. You cannot use a temporary record for the Record parameter.\n## Remarks\nYou can use this method to set the record to display when the user opens the page.\n## Example\nThe following example retrieves the record that has a primary key value of '30000' from the Customer table. If the record is found, it is stored in the MyRecord variable. The SetRecord method uses the retrieved record as the current record and sets record for MyPage, which is a Customer Card page. When the codeunit is run, the record is displayed on the MyPage page. If the record is not found, a message box displays a message that indicates that the record was not found.\n```al\n var\n    MyPage: Page \"Customer Card\";\n    MyRecord: Record Customer;\n    Text000: Label 'The record was not found';\nbegin\n    if MyRecord.Get('30000') then begin\n      MyPage.SetRecord(MyRecord);\n      MyPage.Run;\n    end else begin\n      Message(Text000);\n    end;\nend;\n```\n## Related information\npage-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}