Usina BRAdvPL Guide
Sign in
← All topics
Practical solution guideUnder review

PO-UI in Protheus: develop, build and deploy an interface

From an Angular screen to the .app resource, RPO inclusion and menu launch, with REST integration and acceptance criteria.

PO-UIAngularProtheusFWCallAppRPORESTProtheusLibCoreModuleBuildAPP

What you will achieve

The complete workflow is to develop the Angular interface, build static files, package the .app, compile the resource and AdvPL launcher into the RPO, and open the menu routine. Node.js is used for development and builds; the embedded application uses static files while business logic stays in AppServer. (Refs. 1, 6.)

Start with the local-data laboratory in the examples, then connect REST using the steps below. The deployment owner confirmed that a MRO project opened and loaded orders and details in the client environment. The ed-poui examples in this guide are teaching adaptations and are separate from that validated project.

Open a PO-UI interface from the Protheus menu and, when integrating real data, call REST using the environment session and context.

Before you start

  • Access to the Angular project, a test environment, the customization RPO and menu configuration.
  • An inventory of release, LIB, AppServer, SmartClient/WebApp, Angular, PO-UI, lib-core, Node.js and npm versions.
  • For real data: REST service source, endpoint contracts and the target database dictionary.
Step 01

Inventory the environment

Record the Protheus release, LIB label, AppServer build, SmartClient/WebApp and browser engine versions, TOTVS VS Code extension, Node.js, npm, Angular, PO-UI and lib-core. Use a staging environment with RPO and Configurator access authorized by its administrator.

View code and commands · 1. Check versions before creating the project
node --version
npm --version
npm view @totvs/protheus-lib-core@21.1.4 peerDependencies --json
npm view @po-ui/ng-components@21.35.0 peerDependencies --json
npm view @angular/cli@21 engines --json
Expected result

Compare the output with the documented matrix and record the chosen versions. These commands inspect metadata; they do not certify a Protheus environment. Editorial examples not built as a complete Angular application or compiled in Protheus. Check the matrix and validate on the target release.

Check before continuing

Versions and deployment targets recorded.

Step 02

Check compatibility

Matrix checked on October 30, 2026: @totvs/protheus-lib-core 21.1.4 declares Angular and PO-UI ^21; @po-ui/ng-components 21.35.0 also requires Angular ^21. Angular 21 requires Node ^20.19.0, ^22.12.0 or ^24.0.0 and TypeScript >=5.9 <6.0. These are declared package constraints, not certification for every Protheus environment. Choose a supported LTS line and also check the client browser. Angular latest may be a different major. (Refs. 2–4.)

Check before continuing

Dependencies resolved without forcing installation.

Step 03

Create the screen and configure modules

The example uses NgModule, 2016 file naming and zone.js to make its structure explicit. In standalone projects use the equivalent APIs for the installed version; do not paste app.module.ts into a standalone application. Install compatible majors, inspect npm ls and commit package-lock.json. Then reproduce the environment using npm ci. Do not hide dependency conflicts with --force or --legacy-peer-deps. When adding routes, handle index.html in the existing configuration, for example { path: "index.html", redirectTo: "", pathMatch: "full" }. Do not duplicate RouterModule.forRoot. Also inspect the schematic-generated styles and the installed version’s TOTVS theme, preserving the other project styles.

View code and commands · 2. Create the workspace and install a compatible line
npx --package @angular/cli@21 ng new ed-poui --standalone=false --routing --style=css --ssr=false --zoneless=false --file-name-style-guide=2016
cd ed-poui
npx ng add @po-ui/ng-components@21.35.0
npx ng add @po-ui/ng-templates@21.35.0
npm install --save-exact @totvs/protheus-lib-core@21.1.4
npm ls @angular/core @po-ui/ng-components @totvs/protheus-lib-core
npx ng serve
Expected result

Run in a development folder. Allow the schematic to replace the root screen only in a new project. ng serve checks the local UI without creating a Protheus session. Editorial examples not built as a complete Angular application or compiled in Protheus. Check the matrix and validate on the target release.

View code and commands · 3. Connect modules and interceptors
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { PoModule } from '@po-ui/ng-components';
import { ProtheusLibCoreModule } from '@totvs/protheus-lib-core';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule, AppRoutingModule, PoModule, ProtheusLibCoreModule],
  // Keep lib-core interceptors in HttpClient requests.
  providers: [provideHttpClient(withInterceptorsFromDi())],
  bootstrap: [AppComponent]
})
export class AppModule {}
Expected result

Replace app.module.ts while keeping the generated workspace structure consistent. withInterceptorsFromDi includes class interceptors registered by DI; verify the actual lib-core version’s behavior. Do not create a second HttpClient that bypasses them. (Ref. 8.) Editorial examples not built as a complete Angular application or compiled in Protheus. Check the matrix and validate on the target release.

View code and commands · 4. Create a PO-UI screen with local data
import { Component } from '@angular/core';
import { PoNotificationService, PoTableColumn } from '@po-ui/ng-components';

@Component({
  selector: 'app-root',
  standalone: false,
  template: `
    <po-page-default p-title="PO-UI / Protheus">
      <po-table [p-columns]="columns" [p-items]="items"></po-table>
      <po-button p-label="Check interface" (p-click)="notify()"></po-button>
    </po-page-default>`
})
export class AppComponent {
  columns: PoTableColumn[] = [
    { property: 'id', label: 'Code' },
    { property: 'description', label: 'Description' }
  ];
  // Use local data to check the visual components first.
  items = [
    { id: '01', description: 'Local example' },
    { id: '02', description: 'No ERP access' }
  ];
  constructor(private notification: PoNotificationService) {}
  notify(): void {
    this.notification.success('Local interface ready; integration still needs acceptance tests.');
  }
}
Expected result

Replace the root component in src/app/app.component.ts. The button only displays a notification: data is local and no API or table is changed. id and description are this example’s internal fields, not Protheus table fields. Editorial examples not built as a complete Angular application or compiled in Protheus. Check the matrix and validate on the target release.

Check before continuing

The local screen opens and modules compile.

Step 04

Integrate the Protheus library

Import ProtheusLibCoreModule from @totvs/protheus-lib-core. Older examples refer to protheus-lib-core and a different registry. Do not add corporate logins or tokens to source files. The current README describes interceptors for authentication, the REST URL and company/branch context; resource authorization remains a backend responsibility. (Refs. 1, 2.)

Check before continuing

HttpClient uses lib-core interceptors.

Step 05

Prepare native appConfig

Publish assets/data/appConfig.json in the static output. With Angular 21 assets mapped from public, create public/assets/data/appConfig.json; older workspaces may map src/assets. Inspect angular.json and the generated file instead of assuming a directory. api_baseUrl: "/" follows the documented embedded launch mechanism; a fixed backend URL changes that behavior and is a separate deployment scenario. (Ref. 1.)

View code and commands · 5. Publish application configuration
{
  "name": "ed-poui",
  "version": "1.0.0",
  "api_baseUrl": "/"
}
Expected result

Create public/assets/data/appConfig.json when the workspace uses the default public asset mapping. The built file must exist at assets/data/appConfig.json. ed-poui matches the resource identity. Editorial examples not built as a complete Angular application or compiled in Protheus. Check the matrix and validate on the target release.

Check before continuing

The package includes assets/data/appConfig.json with api_baseUrl "/".

Step 06

Check AppServer

Configure MPP and App_Environment with the AppServer administrator, using the actual environment name and the documentation for the installed LIB/build. Adding a key does not prove that the service started. Schedule any restart and compilation in an approved maintenance window. Do not automatically combine legacy manual HTTP/REST settings with MPP. (Refs. 1, 10, 11.)

View code and commands · 8. Configure the staging AppServer
[General]
App_Environment=HML12
Expected result

The INI fragment is illustrative: replace HML12 with the actual environment; it does not configure networking, certificates or rights by itself. Compile .app and the PRW launcher into the staging RPO before registering U_EDPOUI. Do not pass a developer-machine path to FWCallApp. Editorial examples not built as a complete Angular application or compiled in Protheus. Check the matrix and validate on the target release.

Check before continuing

Native REST is enabled for the selected environment.

Step 07

Build for production

Build a client-side application without requiring an SSR/Node server at runtime. Locate the directory containing index.html, JavaScript, CSS and assets. The application builder may output dist/ed-poui/browser; another builder may produce a different tree. Replacing application with browser is not a universal fix: options and supported versions differ. Investigate bundle budgets rather than removing every limit. (Refs. 6, 7.)

View code and commands · 6. Produce the production build
npm ci
npx ng build --configuration production --base-href ./
Expected result

Inspect angular.json and use the static folder containing index.html. npm ci requires an existing committed package-lock.json; it is not the first command in a folder without a lockfile. Editorial examples not built as a complete Angular application or compiled in Protheus. Check the matrix and validate on the target release.

Check before continuing

Static output includes index.html, bundles and assets.

Step 08

Package the resource

The packaging example follows the named application folder shown in the TOTVS tutorial: ed-poui/index.html inside a ZIP renamed to .app. Check the format accepted by the target LIB’s FwCallApp and inspect the archive before compiling. Include static files and local dependencies, without node_modules, SSR server files, credentials or indispensable CDN links. Preserve the base tag and validate asset resolution inside Protheus. (Refs. 1, 10.)

View code and commands · 7. Package static files as .app
from pathlib import Path
from zipfile import ZipFile, ZIP_DEFLATED
import hashlib
import json
import sys

# Package only the generated static output.
build = Path(sys.argv[1]).resolve()
assert (build / 'index.html').is_file(), 'index.html'
config = build / 'assets/data/appConfig.json'
assert config.is_file(), 'assets/data/appConfig.json'
assert json.loads(config.read_text(encoding='utf-8'))['name'] == 'ed-poui'
artifact = Path('ed-poui.app')
# Preserve the previous artifact for rollback.
with ZipFile(artifact, 'x', ZIP_DEFLATED) as package:
    for file in sorted(build.rglob('*')):
        if file.is_file():
            package.write(file, Path('ed-poui') / file.relative_to(build))
print(hashlib.sha256(artifact.read_bytes()).hexdigest())
Expected result

Save as build_app.py at the workspace root and run, for example, python build_app.py dist/ed-poui/browser. It creates ed-poui.app without overwriting an existing artifact and prints SHA-256. Confirm the layout against the target LIB. Testing this script with simulated files does not validate FWCallApp. Editorial examples not built as a complete Angular application or compiled in Protheus. Check the matrix and validate on the target release.

Check before continuing

The ZIP contains ed-poui/index.html and ed-poui/assets/data/appConfig.json.

Step 09

Compile and apply to the correct environment

In VS Code select the correct server, environment and RPO. Find the allowed extensions setting in the TOTVS extension and add .app without deleting existing entries; the exact setting name varies by version. Compile .app as a resource and compile the launcher .prw. In Configurator create the U_EDPOUI user-function menu entry according to its option type, regenerate the menu and verify rights. Pass ed-poui to FWCallApp, without .app.

View code and commands · 9. Compile the AdvPL launcher and register its menu
#Include "TOTVS.ch"

User Function EdPoUi()
    // The ed-poui.app resource must already be included in this RPO.
    FWCallApp("ed-poui")
Return Nil
Expected result

The INI fragment is illustrative: replace HML12 with the actual environment; it does not configure networking, certificates or rights by itself. Compile .app and the PRW launcher into the staging RPO before registering U_EDPOUI. Do not pass a developer-machine path to FWCallApp. Editorial examples not built as a complete Angular application or compiled in Protheus. Check the matrix and validate on the target release.

Check before continuing

Menu, resource, launcher and service match the RPOs actually loaded.

Step 10

Connect REST and standard fields

Only then add real data: publish a REST endpoint, define its contract and rights, and test it before connecting the UI. Use HttpClient configured with lib-core interceptors; direct fetch calls do not use them. Requests must remain within the authorized backend scope. Do not concatenate user input into SQL or treat client-provided company/branch headers as sufficient authorization.

Check fields in the target SX3 before writing SQL. Virtual fields, such as descriptions resolved through relationships, are not physical columns. Respect sharing for each alias and validate company/branch on the server. Put provisional rules, such as phase calculation, in a dedicated function instead of adding an unnecessary field.

Check before continuing

The endpoint returns real data in the authorized context.

Step 11

Validate inside Protheus

Validate inside Protheus: menu launch; valid and expired sessions; allowed and denied users; company/branch; JS/CSS and appConfig without 404; 401, 403, 404 and 500 handling; timeout and API unavailability; no secrets in the bundle; resource update and back/navigation behavior. The local example does not prove these scenarios.

Check before continuing

Menu opening, list and details checked.

Step 12

Track updates

For updates, version the app and appConfig, retain the previous .app and matching PRW, record the environment/release and repeat build, resource inclusion and acceptance tests. Investigate version and cache behavior before deleting files; any cleanup must be limited to the app and follow the approved operational procedure. Do not delete all of HTTP_ROOT/AppRoot to diagnose one screen.

Check before continuing

Previous version preserved and new version identifiable.

Validate the solution

  • Open the menu routine in the test company/branch and check the list.
  • Select a record and check proposal, budget, parts and services according to the application contract.
  • Distinguish an empty response from an integration failure; do not replace errors with demonstration data.
  • Also test session expiration, denied permissions and company/branch changes. A successful initial load does not cover these cases.

Diagnose by symptom

SymptomWhat to checkHow to resolve it
UnZipApp / FError 161The .app structure and the folder expected by FWCallApp.Keep files under the application-named folder, recompile the resource and reopen. If needed, check permissions and the specific extracted folders.
REST address not suppliedPackaged and extracted appConfig. The query may not have started.Use "/" in the package, recompile and reopen from the menu. Check the resolved address in extracted appConfig and App_Environment.
Service in catalog but HTTP 404The REST used by the session and endpoint path.Confirm registration in the correct process/RPO; do not use /index/mro as a data endpoint.
HTTPS connection failureServer name, client network access and certificate.Preserve the configured protocol and fix certificate trust/name. Do not disable validation as a workaround.
Old screen after compilationLoaded RPO, resource version and extracted copy.Distribute the correct version, reload using the local procedure and reopen. Inspect only application-specific cache; do not delete all of app-root.
SQL reports a missing fieldThe real dictionary and virtual versus physical fields.Check SX3 and resolve descriptions through relationships. Do not add a column just to accommodate a query.

Practical validation and scope

For the MRO project behind this revision, the deployment owner confirmed screen opening and order/detail loading in the client database after correcting the appConfig marker. That project passed a production build and 17 interface tests. This supports the observed workflow without guaranteeing every release, client or business rule.

The ed-poui laboratory on this page remains separate: archive checks using synthetic files do not mean that the complete example was compiled and executed in Protheus. Validate the actual installation before production use.

Common pitfalls
  • ERESOLVE: compare lib-core, PO-UI, Angular, theme, RxJS and zone.js peerDependencies. Installing the latest global CLI may select an incompatible major.
  • Blank screen or missing index: inspect .app as ZIP and check the application folder, index.html, browser output directory, base tag, bundle names and client JavaScript errors.
  • appConfig.json 404: check assets/data publication, asset mapping and the actual build tree; creating the source directory is not enough.
  • Works on localhost but returns 401 inside ERP: inspect the session, preload, interceptors and lib-core initialization. Outside Protheus there is no automatic embedded session; use only the approved development authentication strategy.
  • Investigate 403 as a rights/context issue; do not bypass it by disabling authentication, CORS or backend checks. Tokens do not belong in appConfig, environment.ts, source code, console or the repository.
  • Locked RPO or outdated resource: check the compilation environment and maintenance window. Disconnecting users or changing exclusive-access parameters is not an automatic tutorial step.

Continue reading

References

  1. TOTVS. Getting started with PO-UI — Protheus. Official source consulted; older version examples require updates. Accessed October 30, 2026.
  2. TOTVS. @totvs/protheus-lib-core 21.1.4: metadata, peerDependencies, README and public ProtheusLibCoreModule declaration inspected. Accessed October 30, 2026.
  3. PO UI. @po-ui/ng-components 21.35.0: metadata and peerDependencies inspected. Accessed October 30, 2026.
  4. ANGULAR. Version compatibility: Node.js, TypeScript and RxJS. Accessed October 30, 2026.
  5. ANGULAR. ng new: generation options and naming conventions. Accessed October 30, 2026.
  6. ANGULAR. Building Angular apps: builders and budgets. Accessed October 30, 2026.
  7. ANGULAR. Workspace configuration: outputPath and browser directory. Accessed October 30, 2026.
  8. ANGULAR. withInterceptorsFromDi: DI-registered interceptors. Accessed October 30, 2026.
  9. PO UI. po-angular: README and installation guide. Accessed October 30, 2026.
  10. TOTVS. FwCallApp — Opening Web apps in Protheus. Reference for target-release checks; direct access was limited in this research. Accessed October 30, 2026.
  11. TOTVS. Application Server — Multiprotocol port. Configuration reference for the target environment. Accessed October 30, 2026.
Status
Under review
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR

Was this content helpful?

👍 Like 0👎 Dislike 0

Sign in to rate this article.

0 approved comment(s)

Comments

There are no approved comments yet.

Sign in with Google or Microsoft to comment.

Powered by Usina Docs · Alpha