Customizing the Setup Page
Add per-environment configuration to your agent using a custom setup page.
Overview
Once your agent is deployed as an extension, different environments will likely need different configuration — company name, tone, maybe an API endpoint. Hardcoding those means a recompile each time. The setup page solves that — admins can change values without touching code.
Here we’ll add a custom field and inject it into the instructions dynamically.
Part 1 — Add a Custom Field to the Setup Table
Add a field to your setup table
Open your agent's setup table (the one with User Security ID as the primary key) and add a field for the per-environment value. For example, a description of what product the agent is supporting.
field(20; "Product Description"; Text[250])
{
Caption = 'Product Description';
DataClassification = CustomerContent;
}
Part 2 — Expose the Field on the Setup Page
Add the field to the setup page layout
Open the setup page and add a group for your new field below the standard Agent Setup Part. Setting IsUpdated := true on validate activates the Update button when the value changes.
group(AdditionalConfiguration)
{
Caption = 'Additional Configuration';
field(ProductDescription; Rec."Product Description")
{
ApplicationArea = All;
ToolTip = 'Describe the product this agent supports. This is injected into the agent instructions.';
trigger OnValidate()
begin
IsUpdated := true;
end;
}
}
Save the custom field in SaveCustomProperties
In SaveCustomProperties, make sure the new field gets written to the database alongside the existing ones.
MyAgentSetupRecord."Product Description" := TempMyAgentSetup."Product Description";
Part 3 — Inject the Value into the Instructions
Switch from static to dynamic instructions
In SaveSetupRecord, replace the static instructions with a dynamic version that reads the custom field and merges it in:
local procedure GetInstructions(ProductDescription: Text): Text
var
InstructionsTxt: Label 'You are an agent for a Business Central customer.\\Product context: %1\\Your role is to help users navigate and operate the system efficiently.', Comment = '%1 = product description';
begin
exit(StrSubstNo(InstructionsTxt, ProductDescription));
end;
Then pass the value when calling Agent.SetInstructions:
if IsNewAgent then
Agent.SetInstructions(TempMyAgentSetup."User Security ID",
GetInstructions(TempMyAgentSetup."Product Description"));
Part 4 — Test the Setup Page End-to-End
Publish and delete the existing agent instance
Publish (F5), then delete the agent instance from Stage 7 on the Agents (preview) page so you can create a fresh one through the setup dialog.
Create a new instance and fill in the custom field
Create a new instance. When the setup dialog opens you should see your Product Description field — fill it in and click Update.
Verify the instructions reflect the configured value
Open the agent card and check that your description appears in the Instructions field. Run a task to make sure it's behaving accordingly.
.app that works everywhere — no per-customer forks.