Skip to content

Register Your Copilot

Step 2 of 4

To make your copilot available for users, you need to register it within the application. Here are the steps to register your copilot:

1. Create an Enum Extension

Firstly, you need to extend an existing enum. Navigate to src/1-IdeasCopilot/Registration/ and create an enum that extends Copilot Capability with a unique identifier for your copilot:

enumextension 50200 MyCopilotCapability extends "Copilot Capability"
{
    value(50200; "GPT Ideas Copilot")
    {
        Caption = 'Ideas Copilot';
    }
}

2. Create an Install Codeunit

Next, create an install codeunit to register your copilot when your app is installed. This codeunit should have the subtype Install. Here's the AL code for the OnInstallAppPerDatabase() trigger, which outlines the registration process:

local procedure RegisterCapability()
var
    CopilotCapability: Codeunit "Copilot Capability";
    EnvironmentInformation: Codeunit "Environment Information";
    LearnMoreUrlTxt: Label 'https://training.katson.com/generative-ai-essentials/tasks/ideas-copilot/', Locked = true;
begin
    if EnvironmentInformation.IsSaaS() then
        if not CopilotCapability.IsCapabilityRegistered(Enum::"Copilot Capability"::"GPT Ideas Copilot") then
            CopilotCapability.RegisterCapability(Enum::"Copilot Capability"::"GPT Ideas Copilot", LearnMoreUrlTxt);
end;

Tip

  • Use if EnvironmentInformation.IsSaaS() to make the copilot available only in cloud environments.
  • Remove if EnvironmentInformation.IsSaaS() to enable your copilot in on-premises environments, although standard Microsoft copilots operate in cloud environments only.

Conclusion

By following these steps, you'll have your copilot ready and registered in Dynamics 365 Business Central.

Next Steps

Now, let's move on to creating the user interface for your copilot.