Display errors and messages in Copilot prompt dialogs

Enabled for Public preview General availability
Users, automatically Oct 1, 2024 Oct 1, 2024

Business value

Users learning to work with Copilot often need a simple and effective feedback loop to help them experiment and make the most out of their AI-powered assistant.

Copilot features that display a prompt dialog can now show errors and messages directly inside the dialog. While prompt dialogs aren't intended for conversational experiences, the integrated feedback keeps users focused on the dialog without distraction.

Feature details

Errors and messages that are thrown by the code logic in Copilot prompt dialogs now surface directly inside the dialog rather than in a separate pop-up dialog. There's no additional work required by developers to enable this feature, apart from authoring proper error handling and warnings as you already do today. Both the classic Dialog.Error() and Dialog.Message(), as well as the newer ErrorInfo patterns are supported. In the case of the latter, the title and description will both be shown.

If the code throws more than one message, only the latest will be shown, but the user is told that there were multiple issues. Also, as has already been the case, if an error is thrown, a subsequent message will be suppressed. If the error or message contains line breaks, these are ignored, as opposed to rendering in dialogs.

Example 1: Rendering multiple messages thrown by Message() while in the prompt dialog

The following code snippet illustrates throwing multiple messages, using Message(), when the user chooses the Generate button in a prompt dialog.

page 50110 PromptDialog
{
    PageType = PromptDialog;

    layout
    { ... }

    actions
    {
        area(SystemActions)
        {
            systemaction(Generate)
            {
                trigger OnAction()
                begin
                    Message('First message, which is not shown in the prompt dialog');
                    Message('Last message, which is shown in the prompt dialog');
                end;
            }
        }
    }
}

As a result, when invoking the Generate action in the Copilot prompt dialog, the last message is rendered inline in the Copilot prompt dialog, along with an indication that there were more messages.

Example of rendering a message in the prompt dialog

Example 2: Rendering an error thrown by Error() while in the prompt dialog

Here we instead change to throwing an Error():

page 50110 PromptDialog
{
    PageType = PromptDialog;

    layout
    { ... }

    actions
    {
        area(SystemActions)
        {
            systemaction(Generate)
            {
                trigger OnAction()
                begin
                    Error('This is an example of rendering an error that happens in the prompt dialog, e.g., during Generate');
                end;
            }
        }
    }
}

In this case, the error is rendered inline:

Example of rendering error thrown in prompt dialog

Example 3: Rendering an error thrown by ErrorInfo while in the prompt dialog

The final example illustrates using the recent ErrorInfo type.

page 50110 PromptDialog
{
    PageType = PromptDialog;

    layout
    { ... }

    actions
    {
        area(SystemActions)
        {
            systemaction(Generate)
            {
                trigger OnAction()
                var
                    ErrorInfo: ErrorInfo;
                begin
                    ErrorInfo.Title('Error info title');
                    ErrorInfo.Message('Error message');
                    ErrorInfo.DetailedMessage('Detailed error');

                    Error(ErrorInfo);
                end;
            }
        }
    }
}

In this case, the ErrorInfo message part is rendered inline, and the title part is used for the tooltip. The detailed message is ignored.

Example of rendering ErrorInfo in prompt dialog

Tell us what you think

We're excited to have you with us on our Copilot journey.

Help us improve Dynamics 365 Business Central by discussing ideas, providing suggestions, and giving feedback. Use the forum at aka.ms/bcIdeas, or join the partner discussion on the Dynamics 365 Business Central Partner Community Network on Viva Engage (formerly Yammer) to help us shape the future of AI in Business Central.

See also

Error handling in prompt dialogs (docs)