Usina BRAdvPL Guide
Sign in
← All topics
PRACTICAL GUIDEUnder review

Getting and setting MVC model values

oModel:GetValue(cIdForm,cIdField); oModel:SetValue(cIdForm,cIdField,xValue)

Reads fields and assigns values through Model validation.

Getting and setting MVC model valuesAdvPL
01 · OVERVIEW

Overview

On the root model, GetValue takes submodel ID and field; SetValue also takes the new value and returns logical. The configured model operation affects validation. The grid object has a different signature acting on its current row. LoadValue is not a generic replacement: it requires SetValue in the call stack and skips field validation. Successful SetValue does not confirm persistence; VldData and CommitData are later controlled steps. (Sources: refs. 1–2.)

02 · SYNTAX

Syntax

oModel:GetValue(cIdForm,cIdField); oModel:SetValue(cIdForm,cIdField,xValue)
03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed560()
    // Model, IDs and operation must be prepared; blocks not invoked.
    Local bRead := {|oModel,cForm,cField| oModel:GetValue(cForm,cField)}
    Local bUpdate := {|oModel,cForm,cField,xValue| oModel:SetValue(cForm,cField,xValue)}
    ConOut(ValType(bRead)+ValType(bUpdate))
Return Nil
Expected result

Prints BB. When integrating, check SetValue’s logical result and model errors. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Use actual structure fields/IDs, inspect errors and avoid bypassing validation with direct writes. In grids, preserve position and validate row/model before persistence.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. FWFormModel. TDN. Accessed on 2026-10-27.
  2. TOTVS. FWFormGridModel. 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