{"title":"Error handling in prompt dialogs","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/devenv-page-prompt-error-handling/","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-page-prompt-error-handling, 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-page-prompt-error-handling","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":"Discover how to manage errors directly within Copilot prompt dialogs in Business Central.","date":"2026-10-02","meta":{"topic":"overview"},"outline":[{"level":1,"title":"Error handling in prompt dialogs","slug":"error-handling-in-prompt-dialogs","at":0,"chars":3747},{"level":2,"title":"Example 1: Rendering multiple messages thrown by `Message()` in the prompt dialog","slug":"example-1-rendering-multiple-messages-thrown-by-message-in-the-prompt-dialog","at":1002,"chars":891},{"level":2,"title":"Example 2: Rendering an error thrown by `Error()` in the prompt dialog","slug":"example-2-rendering-an-error-thrown-by-error-in-the-prompt-dialog","at":1893,"chars":641},{"level":2,"title":"Example 3: Rendering an error thrown by ErrorInfo in the prompt dialog","slug":"example-3-rendering-an-error-thrown-by-errorinfo-in-the-prompt-dialog","at":2534,"chars":953},{"level":2,"title":"Related information","slug":"related-information","at":3487,"chars":260}],"text":"# Error handling in prompt dialogs\n> CHANGED IN: Business Central 2024 release wave 2\nError handling is a critical aspect of creating seamless user experiences in applications. In Business Central 2024 release wave 2, enhancements to Copilot prompt dialogs allow errors and messages to be displayed directly within the dialog, eliminating the need for separate popup dialogs. This documentation explains how to use supported error patterns, such as `Dialog.Error()`, `Dialog.Message()`, and ErrorInfo, to manage errors effectively in prompt dialogs. You'll also find examples demonstrating how these patterns work, along with best practices for rendering messages and errors inline.\nIf the code throws more than one message, only the last message is shown, but the user is informed about the total number of issues. If an error is thrown, any subsequent message is suppressed. If the error or message contains line breaks, these line breaks are ignored, as opposed to when they're rendered in dialogs.\n## Example 1: Rendering multiple messages thrown by `Message()` in the prompt dialog\nThe following code snippet illustrates throwing multiple messages, using `Message()`, when the user chooses the Generate button in a prompt dialog.\n```al\npage 50110 PromptDialog\n{\n    PageType = PromptDialog;\n\n    layout\n    { ... }\n\n    actions\n    {\n        area(SystemActions)\n        {\n            systemaction(Generate)\n            {\n                trigger OnAction()\n                begin\n                    Message('First message, which isn''t shown in the prompt dialog');\n                    Message('Last message, which is shown in the prompt dialog');\n                end;\n            }\n        }\n    }\n}\n```\nWhen you select the Generate action in the Copilot prompt dialog, the last message appears inline in the Copilot prompt dialog, along with an indication that there were more messages.\n## Example 2: Rendering an error thrown by `Error()` in the prompt dialog\nIn this example, an `Error()` is thrown when the user chooses the Generate button in a prompt dialog.\n```al\n\npage 50110 PromptDialog\n{\n    PageType = PromptDialog;\n\n    layout\n    { ... }\n\n    actions\n    {\n        area(SystemActions)\n        {\n            systemaction(Generate)\n            {\n                trigger OnAction()\n                begin\n                    Error('This is an example of rendering an error that happens in the prompt dialog, e.g. during Generate');\n                end;\n            }\n        }\n    }\n}\n```\nHere, the error appears inline.\n## Example 3: Rendering an error thrown by ErrorInfo in the prompt dialog\nThe last example illustrates using the ErrorInfo type when the user chooses the Generate button in a prompt dialog.\n```al\npage 50110 PromptDialog\n{\n    PageType = PromptDialog;\n\n    layout\n    { ... }\n\n    actions\n    {\n        area(SystemActions)\n        {\n            systemaction(Generate)\n            {\n                trigger OnAction()\n                var\n                    ErrorInfo: ErrorInfo;\n                begin\n                    ErrorInfo.Title('Error info title');\n                    ErrorInfo.Message('Error message');\n                    ErrorInfo.DetailedMessage('Detailed error');\n\n                    Error(ErrorInfo);\n                end;\n            }\n        }\n    }\n}\n```\nHere, the ErrorInfo message appears inline, and the title is used as a tooltip. The detailed message is ignored.\n![Example of rendering an errorinfo message in the prompt dialog]\n## Related information\ndevenv-page-type-promptdialog\nPrompting using a floating action bar<devenv-page-prompting-floating-actionbar>\nPrompting using a prompt guide<devenv-page-promptguide>\nUser experience guidelines for errors<devenv-error-handling-guidelines>"}