Ir al contenido

Altering the UI (PageExtension)

Modification of the ERP visual layer to show new fields, hide elements, and alter the layout using AL.

0views

To complete the development cycle of a new feature, once the database has been modified, we must intervene in the presentation layer.

The pageextension object allows us to inject our new fields into existing screens, move site elements, and even hide (modify the visibility of) columns that generate “visual noise” for the user.

Unlike traditional web pages based on pure HTML, Business Central pages are a hierarchical tree of metadata. To insert our field, we must use spatial modifiers (“Anchors”) to tell the system exactly where to place it relative to an existing standard field.

The available modifiers are:

  • addbefore(CampoDestino): Inserts it just to the left (or above).
  • addafter(CampoDestino): Inserts it just to the right (or below).
  • addfirst(GrupoDestino): Inserts it as the first element of a container.
  • addlast(GrupoDestino): Inserts it as the last element of a container.
  • moveafter(CampoDestino, MiCampo): To reorder existing fields.

2. Development: Injecting our field into the UI

Sección titulada «2. Desarrollo: Inyectando nuestro campo en la UI»

Following our “End Supplier” scenario (created in the previous module in table 121), we must now display it. Since we have identified that the company uses two different windows to view this table, we must perform two independent pageextension.

The standard page that shows the receipt lines is 528 (“Posted Purchase Rcpt. Subform”). We are going to place our field just to the right of the item description.

File: Pag-Ext50100.PurchRcptLinesExt.al

// 1. Declaración y enlace a la página original
pageextension 50100 "Portelcore PurchRcptLines Ext" extends "Posted Purchase Rcpt. Subform"
{
layout
{
// 2. Punto de anclaje visual (Inmediatamente después de "Description")
addafter(Description)
{
// 3. Declaración del campo a mostrar (Rec es el puntero al registro actual)
field("Proveedor Final"; Rec."Proveedor Final")
{
// ApplicationArea es obligatorio. Si no se pone, el campo queda invisible por seguridad.
ApplicationArea = All;
// Texto de ayuda (Hover) para guiar al usuario
ToolTip = 'Indica el nombre del fabricante original de la materia prima (Analítica DevSecOps).';
// Propiedades de formato (opcionales)
ShowMandatory = true; // Pone un asterisco rojo (aunque no fuerza el error en la base de datos)
// Nota arquitectónica: En páginas de histórico (Albaranes Registrados),
// por norma general los campos deberían ser de solo lectura.
Editable = false;
}
}
}
}

We have detected that the warehouse team does not use page 528, but rather a simplified one created internally called Lineas albaran compra (Page 50017). For them, the field must be very visible and located next to the quantity.

File: Pag-Ext50101.CustomPurchRcptLinesExt.al

pageextension 50101 "Portelcore CustomRcptLines Ext" extends "Lineas albaran compra"
{
layout
{
addafter(Quantity)
{
field("Proveedor Final"; Rec."Proveedor Final")
{
ApplicationArea = All;
ToolTip = 'Fabricante de origen.';
// Destaque visual: Pone el texto en negrita
Style = Strong;
}
}
}
}

With this final step, we have completed the data “Triforce” in a modern DevSecOps environment:

  1. Persistence (Backend): We create the physical space in SQL via tableextension. The underlying system begins to operate with it.
  2. Interaction (Frontend): We provide humans with read/write points via pageextension in all required interfaces.
  3. Analysis (Data Pipeline): We invisibly and at high speed export that same data via Query APIs to our Business Intelligence (Power BI) repositories.
  • ✓ ApplicationArea: ApplicationArea = All property explicitly defined in each injected field to prevent the engine from hiding it.
  • ✓ Accessibility: Inclusion of descriptive ToolTips in all visual controls.
  • ✓ Business Restrictions: Editable = false property implemented on history or read-only pages to ensure the immutability of accounting data.