Bearbeiten

Freigeben über


Prompting using a floating action bar

Note

With Business Central 2024 release wave 2 and runtime 14, you can also use prompt actions on Card, Document, and ListPlus page types to nudge users to use your Copilots on such pages. The required AL code follows the same model as when adding Copilot prompt actions to list pages.

Since Business Central 2024 release wave 1 and runtime 13, you can create prompt actions to promote AI capabilities in Business Central. A prompt action is a standard action that is rendered with more prominence than other actions in the UI. It can be shown as a floating action bar on your pages, and it nudges users to use relevant Copilot built-in features.

The following image shows what the floating action bar can look like.

Example of a floating action bar for Copilot feature

To create a floating action bar with one or more prompt actions, you must create a new area in the actions section of the page object. The area must be set to area(Prompting). You can then create one or more new actions in the area and run a PromptDialog object that you want to activate when the action is clicked. Only objects of the PromptDialog page type can be run from a prompting area.

Note

The floating action bar only shows if you've specified a RunObject property to the page.

The following example shows the syntax for how to create a prompt action that runs the Copilot Marketing Text page. This piece of AL code can be added to a page where you want to promote the Copilot Marketing Text functionality. When the action is clicked, the Copilot Marketing Text page is opened in a dialog.

...
actions
{
    area(Prompting)
    {
        action(MyPromptAction)
        {
            Caption = 'Copilot Marketing Text';
            RunObject = page "Copilot Marketing Text";
        }
    }
}
...

Note

The user sees a floating action bar on the page that this code is implemented on. If the user selects Hide, the floating action bar is placed in the action bar instead. It can easily be brought back by clicking Show in page.

The next code is part of a code sample taken from the aka.ms/BCTech repo; the Job Planning Lines Copilot page extension. This code sample illustrates how to create two prompt actions that run the SuggestResourceCopilotAction and SuggestItemCopilotAction actions. The SuggestResourceCopilotAction action is used to suggest a resource to be assigned to a job planning line, and the SuggestItemCopilotAction action is used to suggest an item to be assigned to a job planning line. The SuggestResourceWithAI and SuggestItemWithAI functions aren't implemented in this code sample.

...
actions
    {
        addlast(Prompting)
        {
            action(SuggestResourceCopilotAction)
            {
                Caption = 'Suggest resource';
                ToolTip = 'Asks Copilot which resource can be assigned to the job planning line. You will have to confirm the suggestion from Copilot.';
                Visible = Rec.Type = Rec.Type::Resource;
                ApplicationArea = All;

                trigger OnAction()
                begin
                    SuggestResourceWithAI(Rec);
                end;
            }
        }
        addlast(Prompting)
        {
            action(SuggestItemCopilotAction)
            {
                Caption = 'Suggest item';
                ToolTip = 'Asks Copilot which item can be assigned to the job planning line. You will have to confirm the suggestion from Copilot.';
                Visible = Rec.Type = Rec.Type::Item;
                ApplicationArea = All;

                trigger OnAction()
                begin
                    Message('not implemented');
                end;
            }
        }
    }
...

The PromptDialog page type
Prompting using a prompt guide
Error handling in prompt dialogs