Usina BRAdvPL Guide
Sign in
← All topics
COMMANDUnder review

NEW MODEL in AdvPL

NEW MODEL TYPE nType DESCRIPTION cDescription BROWSE oBrowse SOURCE cSource [MODELID cModelID] MASTER cMasterAlias

Generates MVC structure through a preprocessor command.

NEW MODEL in AdvPLAdvPL
01 · OVERVIEW

Overview

In the consulted public FWMVCDef.ch copy, NEW MODEL is an #xcommand expanding browse, ModelDef, ViewDef and, in one variant, MenuDef. TYPE 1 represents one entity; types 2/3 require a relation. This example uses fictitious ZZ1 only and must not be combined with duplicate manual definitions of generated functions. The GitHub copy is an analysis reference, not an official distribution or proof of current-LIB compatibility. (Sources: refs. 1–3.)

02 · SYNTAX

Syntax

NEW MODEL TYPE nType DESCRIPTION cDescription BROWSE oBrowse SOURCE cSource [MODELID cModelID] MASTER cMasterAlias

Parameters

TYPE
NumericRequired

1 for this single-entity example.

DESCRIPTION
CharacterRequired

Descriptive title.

BROWSE
ObjectRequired

Variable receiving the generated browse.

SOURCE
CharacterRequired

Routine base name.

MODELID
CharacterOptional

Model ID distinct from the User Function.

MASTER
CharacterRequired

Dictionary-registered alias.

Return value

Preprocessor command; not a single-return function.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"
#Include "FWMVCDef.ch"

User Function Ed557()
    Local oBrowse
    // Requires ZZ1 in SX2/SX3 and review of generated permissions.
    NEW MODEL ;
        TYPE 1 ;
        DESCRIPTION "Test register" ;
        BROWSE oBrowse ;
        SOURCE "ED557" ;
        MODELID "ED557M" ;
        MASTER "ZZ1"
// The command itself expands Return and Static MVC functions.
Expected result

When compiled and called in a prepared environment, the routine opens the generated browse; it was not executed. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Check the LIB-supplied include; do not replace it with the public copy. Prepare fictitious-table SX2/SX3 and permissions before staging. Inspect preprocessed output and avoid duplicate ModelDef/ViewDef/MenuDef definitions in the same PRW.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. imsys/Protheus-Include. Cópia pública de fwmvcdef.ch; arquivo lido integralmente, commit 7b56abf. Accessed on 2026-10-27.
  2. TOTVS. MPFormModel. TDN. Accessed on 2026-10-27.
  3. TOTVS. FWFormView. TDN. Accessed on 2026-10-27.
Status
Under review
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR
0 approved comment(s)

Comments

There are no approved comments yet.

Sign in with Google or Microsoft to comment.

Powered by Usina Docs · Alpha