Share via


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 get the most from their AI-powered assistant.

Copilot features that display a prompt dialog now show errors and messages directly in the dialog. Although prompt dialogs don't support conversational experiences, the integrated feedback helps users stay focused on the dialog.

Feature details

Errors and messages that the code logic throws in Copilot prompt dialogs now appear directly inside the dialog instead of showing up in a separate pop-up dialog. Developers don't need to do any extra work to turn on this feature. Just author error handling and warnings like you do today. The feature supports both the classic Dialog.Error() and Dialog.Message() patterns, as well as the newer ErrorInfo pattern. For the ErrorInfo pattern, the dialog shows both the title and description.

If the code throws multiple messages, the dialog shows only the latest message. The user sees a notification that multiple issues exist. If an error is thrown, the dialog suppresses any subsequent message. If the error or message contains line breaks, the dialog ignores these line breaks instead of rendering them.

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

The following code snippet shows how to throw multiple messages with Message() when the user selects Generate 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;
            }
        }
    }
}

When you select Generate in the Copilot prompt dialog, the last message appears inline in the Copilot prompt dialog. The dialog also shows that more messages exist.

Example of rendering a message in the prompt dialog

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

In the following example, you throw 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;
            }
        }
    }
}

The error appears inline:

Example of rendering error thrown in prompt dialog

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

The last example shows how to use the 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 example, the prompt dialog renders the ErrorInfo message part inline and uses the title part for the tooltip. The dialog ignores the detailed message.

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 shape the future of AI in Business Central.

Geographic areas

Visit the Explore Feature Geography report for Microsoft Azure areas where this feature is planned or available.

Language availability

Visit the Explore Feature Language report for information on this feature's availability.

Tell us what you think

Help us improve Dynamics 365 Business Central by discussing ideas, providing suggestions, and giving feedback. Use the forum at https://aka.ms/bcideas.

Additional resources

Error handling in prompt dialogs (docs)