An example Per-Tenant Extension for Business Central that demonstrates how to extend the NP Retail POS data sources with custom fields.
The POS frontend displays data from three built-in data sources. Partners can add custom fields to any of them using integration events, making the fields available across the POS UI — in grids, footer, product panel, and more.
| Data Source | Constant | Available in UI areas |
|---|---|---|
BUILTIN_SALELINE |
POSDataSource_BuiltInSaleLine() |
Sale Lines grid, Footer, Product Panel |
BUILTIN_SALE |
POSDataSource_BuiltInSale() |
Sale grid, Sale Totals, Footer, Product Panel |
BUILTIN_PAYMENTLINE |
POSDataSource_BuiltInPaymentLine() |
Payment grid, Payment Totals, Footer, Product Panel |
Note: The Totals values (e.g. AmountExclVAT, TotalAmount, SaleAmount, PaidAmount) are hardcoded in core and are not extensible via this mechanism.
Each extension subscribes to three integration events on the NPR POS Data Management codeunit:
OnDiscoverDataSourceExtensions— Register your extension name for a data source.OnGetDataSourceExtension— Define your custom columns (name, caption, data type, visibility).OnDataSourceExtensionReadData— Provide the actual field values for each row.
Once deployed, the new fields automatically appear in the POS View Profile configuration, where the user can toggle visibility, rename captions, and set alignment.
This app contains three example codeunits, one for each data source:
Folder: src/SaleLineExtension/
Adds a "Vendor Item No." column to the sale line grid by looking up the vendor item number from the Item table.
Folder: src/SaleExtension/
Adds a "Customer Phone No." field to the sale data source by looking up the phone number from the Customer table. Available in the Sale grid, Sale Totals area, Footer, and Product Panel.
Folder: src/PaymentLineExtension/
Adds a "Payment Method Desc." column to the payment line data source by looking up the description from the NPR POS Payment Method table.
Below is the minimal code needed to add a custom field to the sale line grid:
codeunit 50100 "PTE Vendor Item No. DS Ext."
{
Access = Internal;
local procedure ExtensionName(): Text
begin
exit('VendorItemNo');
end;
[EventSubscriber(ObjectType::Codeunit, Codeunit::"NPR POS Data Management",
'OnDiscoverDataSourceExtensions', '', false, false)]
local procedure OnDiscover(DataSourceName: Text; Extensions: List of [Text])
var
POSDataMgt: Codeunit "NPR POS Data Management";
begin
if DataSourceName <> POSDataMgt.POSDataSource_BuiltInSaleLine() then
exit;
Extensions.Add(ExtensionName());
end;
[EventSubscriber(ObjectType::Codeunit, Codeunit::"NPR POS Data Management",
'OnGetDataSourceExtension', '', false, false)]
local procedure OnGetExtension(DataSourceName: Text; ExtensionName: Text;
var DataSource: Codeunit "NPR Data Source"; var Handled: Boolean;
Setup: Codeunit "NPR POS Setup")
var
POSDataMgt: Codeunit "NPR POS Data Management";
DataType: Enum "NPR Data Type";
begin
if (DataSourceName <> POSDataMgt.POSDataSource_BuiltInSaleLine())
or (ExtensionName <> ExtensionName())
then
exit;
Handled := true;
DataSource.AddColumn(ExtensionName(), 'Vendor Item No.', DataType::String, false);
end;
[EventSubscriber(ObjectType::Codeunit, Codeunit::"NPR POS Data Management",
'OnDataSourceExtensionReadData', '', false, false)]
local procedure OnReadData(DataSourceName: Text; ExtensionName: Text;
var RecRef: RecordRef; DataRow: Codeunit "NPR Data Row";
POSSession: Codeunit "NPR POS Session";
FrontEnd: Codeunit "NPR POS Front End Management"; var Handled: Boolean)
var
SaleLinePOS: Record "NPR POS Sale Line";
Item: Record Item;
POSDataMgt: Codeunit "NPR POS Data Management";
VendorItemNo: Text;
begin
if (DataSourceName <> POSDataMgt.POSDataSource_BuiltInSaleLine())
or (ExtensionName <> ExtensionName())
then
exit;
Handled := true;
RecRef.SetTable(SaleLinePOS);
if (SaleLinePOS."Line Type" = SaleLinePOS."Line Type"::Item)
and Item.Get(SaleLinePOS."No.")
then
VendorItemNo := Item."Vendor Item No.";
DataRow.Fields().Add(ExtensionName(), VendorItemNo);
end;
}After deploying the extension:
- Login into the POS
- Open POS Editor
- Go to the Sale Lines / Totals / Footer / Product Panel tab
- Your new fields will appear in the field selection of extended data source
- Enable them (Optionally: configure captions and alignment if needed)
- NP Retail installed on your Business Central environment.
- The
app.jsondependency version for NP Retail must match the version installed on your target environment.