PARAMIXB[1]Model or form object, depending on the event.
AdvPL GuideUser Function ITEM()MATA010 maintains product records in SB1. Its documented MVC model identifier is ITEM: implement User Function ITEM() and dispatch the events received in PARAMIXB[2]. Conventional names remain in the mapping for reference and compatibility.
Each card is an event received by the same User Function ITEM(), not a separate function. All code panels repeat the same complete dispatcher: use one ITEM source and combine handling there. The diagram shows phases; an event is not guaranteed to run only once.
User Function ITEM()PARAMIXB[1]Model or form object, depending on the event.
PARAMIXB[2]MVC event identifier received by function ITEM.
PARAMIXB[3]Form or submodel identifier; do not confuse it with the entry function name.
MODELPOS validates the whole model and expects logical. MODELCOMMITTTS runs inside the transaction; MODELCOMMITNTTS runs outside it. Returning Nil from a persistence event does not block processing. Standard code controls Begin Transaction and completion.
#Include "Protheus.ch"
#Include "FWMVCDef.ch"
/*/{Protheus.doc} ITEM
One function receives the events for model ITEM.
@type User Function
@author Usina.BR
@since 31/10/2026
@return variant
/*/
User Function ITEM()
Local aContext := PARAMIXB
Local oContext := Nil
Local cEvent := ""
Local cForm := ""
Local xReturn := .T.
// Check the envelope before reading documented positions.
If ValType(aContext) != "A"
Return xReturn
EndIf
If Len(aContext) < 3
Return xReturn
EndIf
If ValType(aContext[2]) != "C"
Return xReturn
EndIf
oContext := aContext[1]
cEvent := aContext[2]
cForm := aContext[3]
Do Case
Case cEvent == "MODELVLDACTIVE" .Or. ;
cEvent == "MODELPOS" .Or. cEvent == "FORMPOS"
// No custom rule: allow validation in this skeleton.
xReturn := .T.
Case cEvent == "BUTTONBAR"
// No extra buttons in this example.
xReturn := {}
Case cEvent == "FORMCOMMITTTSPRE" .Or. ;
cEvent == "FORMCOMMITTTSPOS"
// Before form persistence; the return does not block processing.
xReturn := Nil
Case cEvent == "MODELCOMMITTTS"
// Complementary handling inside the transaction, with no external effect.
xReturn := Nil
Case cEvent == "MODELCOMMITNTTS"
// Handling outside the transaction; do not run the same integration twice.
xReturn := Nil
EndCase
Return xReturnEditorial skeleton, not compiled or executed in Protheus during this review. It neutrally dispatches the displayed events, implements no business rules, writes no tables and calls no external services. Validate release-specific events, submodels and operations before customizing. Do not publish multiple sources containing User Function ITEM().
© 2026 Usina.BR. All rights reserved. TOTVS, Protheus, Microsiga and their respective logos are trademarks of their owners. AdvPL Guide is independent and uses limited, attributed excerpts justified by educational purposes. See the Terms of Use. Terms of Use
Comments
There are no approved comments yet.
Sign in with Google or Microsoft to comment.