{"title":"Page.RunModal() Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/page/page-runmodal--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-runmodal--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-runmodal--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":"Creates, opens, and closes a page that you specify.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":2,"title":"Syntax","slug":"syntax","at":233,"chars":50},{"level":2,"title":"Parameters","slug":"parameters","at":283,"chars":85},{"level":2,"title":"Return Value","slug":"return-value","at":368,"chars":1104},{"level":2,"title":"Remarks","slug":"remarks","at":1472,"chars":587},{"level":2,"title":"Example","slug":"example","at":2059,"chars":453},{"level":2,"title":"Related information","slug":"related-information","at":2512,"chars":132}],"text":"> Version: _Available or changed with runtime version 1.0._\nCreates, opens, and closes a page that you specify. When a page is run modally, no input, such as a keyboard or mouse click, can occur except for objects on the modal page.\n## Syntax\n```al\n[Action := ]  Page.RunModal()\n```\n## Parameters\nPage\nType: page-data-type\nAn instance of the page-data-type data type.\n## Return Value\n*[Optional] Action*\nType: ../action/action-option\nSpecifies what action the user took on the page.\nSpecifies what action the user took on the page. The following table shows the possible return values for the different user actions.\nReturn value|Description\nOK|To close the page window, the user does one of the following:<br /><br /> - Chooses the Close button.<br />- Chooses the X button when there is no Cancel button on the window.\nCancel|To close the page window, the user does one of the following:<br /><br /> - Chooses the Cancel button.<br />- Chooses the X button when there is a Cancel button on the window.\nLookupOK|To close a lookup window, the user chooses the OK button.\nLookupCancel|To close a lookup window, the user chooses the Cancel button.\nYes|To close a confirmation window, the user selects Yes.\nNo|To close a confirmation window, the user does one of the following:<br /><br /> - Chooses the No button.<br />- Chooses the X button.\nRunObject|The user selected an option that ran another object.\nRunSystem|The user selected an option that ran an external program.\n## Remarks\nIf you know the specific page that you want to run when you are designing your application, then you can create a Page variable, set the Subtype of the variable to a specific page, and then use this method or the page-run--method.\nIf you don't know the specific page that you want to run, then use the page-run--method or the RunModal Method \\(Page\\) and specify the page in the Number parameter.\nAfter you define the page variable, you can use it before and after you run the page. If you use the page-run--method, then you can only use the variable before you run the page.\n## Example\nThis example shows how to use this method. Assume that the SomePage variable has been defined as `Page 1`.\n```al\nClear(SomePage);\nSomePage.XXX; // Any user-defined method\nSomePage.SetTableView(MyRecord);\nSomePage.SetRecord(MyRecord);\nif SomePage.RunModal = Action::LookupOK then\n  SomePage.GetRecord(MyRecord)...\n```\n> NOTE\n> This code example includes the ../system/system-clear-joker-method to make sure that the variable has been cleared.\n## Related information\npage-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}