Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

GetAdvFVal

GetAdvFVal(cKeyAlias,uCpo,[uChave],[nOrder],[uDef]) -> uRet

Looks up a key and returns one or multiple fields.

GetAdvFValAdvPL
01 · OVERVIEW

Overview

cKeyAlias identifies the table and uCpo takes a field name or an array of names. uChave and nOrder must match the actual index, including branch and dictionary lengths; uDef supplies a fallback for missing keys. The illustrative block takes a completed key without automatically querying; SA1 must be available in the correct environment. (Sources: refs. 1–1.)

02 · SYNTAX

Syntax

GetAdvFVal(cKeyAlias,uCpo,[uChave],[nOrder],[uDef]) -> uRet

Parameters

cKeyAlias
CharacterRequired

Table alias.

uCpo
Character or arrayRequired

Field or field list.

uChave
CharacterOptional

Complete index key.

nOrder
NumericOptional

Index order.

uDef
AnyOptional

Compatible fallback.

Return value

Field value or array of values.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed463()
    // Complete key according to test-environment SIX and SX3.
    Local bLookup := {|cKey| GetAdvFVal("SA1",{"A1_NOME","A1_TIPO"},cKey,1,{"",""})}
    ConOut(ValType(bLookup))
Return Nil
Expected result

Prepares a two-field lookup with a two-position fallback array. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • A result equal to the fallback does not distinguish a missing key from a legitimately empty value. Validate existence separately when that distinction matters.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. GetAdvFVal. 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