Are you still using ApplicationArea = All in your PTE code? In this blog will learn how we can extend ApplicationArea ensuring that users only see relevant features based on their role, license, or company setup. By default, Business Central offers standard areas like Basic, Suite, and Advanced, but developers can extend these with custom Application Areas to tailor experiences for specific extensions or modules.
The problem with ApplicationArea =All is that in some companies you might not want certain areas (modules) used. For example, my custom fields related to an advanced delivery PTE will be used in one company and not all. Using ApplicationArea = DeliveryArea and enabling in the target company would hide the fields in all other companies simplifying the business logic triggered by UI.
Let’s see what’s needed:
- Extend Application Area Setup
tableextension 50121 "Application Area Setup" extends "Application Area Setup"
{
fields
{
field(50100; "Delivery Area"; Boolean)
{
}
}
}
2. Enable it for an experience:
codeunit 50100 "Enable Custom Area"
{
// Extend and modify Essential experience tier with "Delivery App Area"
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Application Area Mgmt.", 'OnGetEssentialExperienceAppAreas', '', false, false)]
local procedure RegisterCustomAreaOnGetEssentialExperienceAppAreas(var TempApplicationAreaSetup: Record "Application Area Setup" temporary)
begin
TempApplicationAreaSetup."Delivery Area" := true;
// Modify other application areas here
end;
// Validate that application areas needed for the extension are enabled
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Application Area Mgmt.", 'OnValidateApplicationAreas', '', false, false)]
local procedure VerifyApplicationAreasOnValidateApplicationAreas(ExperienceTierSetup: Record "Experience Tier Setup"; TempApplicationAreaSetup: Record "Application Area Setup" temporary)
begin
if ExperienceTierSetup.Essential then
if not TempApplicationAreaSetup."Delivery Area" then
Error('Trading Area should be part of Essential in order for the Example Extension to work.');
end;
// Helpers ................................................................
procedure IsDeliveryAreaEnabled(): Boolean
var
ApplicationAreaSetup: Record "Application Area Setup";
ApplicationAreaMgmtFacade: Codeunit "Application Area Mgmt. Facade";
begin
if ApplicationAreaMgmtFacade.GetApplicationAreaSetupRecFromCompany(ApplicationAreaSetup, CompanyName()) then
exit(ApplicationAreaSetup."Delivery Area");
end;
procedure EnableCustomArea()
var
ApplicationAreaMgmtFacade: Codeunit "Application Area Mgmt. Facade";
begin
ApplicationAreaMgmtFacade.RefreshExperienceTierCurrentCompany();
end;
}
3. Enable it on your experience/company during installation:
codeunit 50101 "Install Example Extension"
{
Subtype = Install;
trigger OnInstallAppPerCompany()
var
EnableApplicationArea: Codeunit "Enable Custom Area";
begin
if (EnableApplicationArea.IsDeliveryAreaEnabled()) then
exit;
EnableApplicationArea.EnableCustomArea();
end;
}
4. Use it for your custom fields:
tableextension 50120 Customer extends Customer
{
fields
{
field(50120; DeliveryID; Text[10])
{
DataClassification = ToBeClassified;
}
}
}
pageextension 50120 CustCardExt extends "Customer Card"
{
layout
{
addafter(General)
{
group(DeliveryGroup)
{
Caption = 'Delivery';
field(DeliveryID; Rec.DeliveryID)
{
ApplicationArea = DeliveryArea;
Caption = 'Delivery ID';
}
}
}
modify(Address)
{
Caption = 'Delivery Address Details';
ApplicationArea = DeliveryArea;
}
}
}
For more information read Microsoft Learn articles:
Extending Application Areas – Business Central | Microsoft Learn
ApplicationArea property – Business Central | Microsoft Learn
And of course, if you have not subscribed yet to my channel, my 10 minutes video tutorial:


