fieldvalue(
fieldvalue(
DATABASE
,
DATAFIELD
)

The fieldvalue( function grabs the contents of a field in the current record of a database. You can grab data from the current database, or from another database.

Parameters

This function has two parameters:

database – is the database that you want to grab data from. This database must be currently open. If this parameter is `""` or omitted then the current database will be used.

datafield – is the name or number of the field that you want to retrieve data from. This must be a field in the database specified by the first parameter. If a number is specified, the first field is 1, the second field is 2, etc.

Description

The function returns the contents of the specified field in the specified database. Unlike lookup( functions, the fieldvalue( function does not search for the data, it simply uses whatever data is in the currently active record of the specified database.

This example grabs the currently selected item in a Price List database and copies it into the Item and Price fields in the current database (perhaps an invoice).

    Item=fieldvalue("Price List",Part)
    Price=fieldvalue("Price List",Price)

The drawback of the fieldvalue( function is that the user must manually locate the data, but sometimes this is exactly what you want. You can also use the fieldvalue( function to grab data from the current record, but where you need to calculate the field name on the fly. Suppose you have a database that has four fields for phone numbers: Phone1, Phone2, Phone3, Phone4. Another field, PrimaryPhone, contains a number (1–4) telling which of these phone numbers is the primary phone number. The procedure below will dial the primary phone number.

    dial fieldvalue("Phone"+str(PrimaryPhone))

If the formula calculating the field name is a single field or variable, you must add at least one operator to the formula. For example, `fieldvalue(Primary+"")` tells Panorama to grab the contents of the field whose name is in Primary. The formula `fieldvalue(Primary)`, however, tells Panorama to grab the contents of the field Primary itself. (Note: In Panorama 6 you could do this by adding parentheses to the field name, but that does not work in Panorama X, there must be at least one operator for Panorama to treat this parameter as a formula.)

Another use for the fieldvalue( function is to ensure that you are getting a value from a field and not a variable. Normally, if there is a variable with the same name as a field, you won’t be able to access the contents of the field. Use the fieldvalue( function if you want to make sure you are getting a field value, even if there is a variable of the same name.

    select fieldvalue("Company") contains "acme"

In an application like this, using fieldvalue( is faster than simply using the variable name (because Panorama doesn’t have to check to see if there is a variable with this name).

You can also reference the field by number. This example displays the contents of the field to the right of the current field. (If the current field is the farthest right field in the database, this example will return an error.)

    message fieldvalue(info("fieldnumber")+1)

Note: In Panorama 6.0 and earlier, this function was called `grabdata(`. This function name is still allowed for compatibility with legacy databases.

See Also

- arraybuild( -- builds an array by scanning a database and creating an array element for every record (including invisible records) in the database (see Text Arrays).
- arrayselectedbuild( -- builds an array by scanning a database and creating an array element for every visible (selected) record in the database (see Text Arrays).
- formulavalue( -- calculates the result of a formula based on data in the current record of any open database. This is similar to the fieldvalue( function, but allows any formula to be used, rather than just a single field.
- globaldictionarybuild -- builds a global dictionary by scanning a database.
- join -- joins data from another database into the current database.
- joinonerecord -- joins matching data from another database into the current record.
- lastlookupdatabase( -- returns the name of the database referenced in the most recent lookup.
- lookup( -- searches a database for a value, then returns other information from the same record. For example, the *lookup(* function can look up a phone number given a customer name, or look up a price given a part number.
- lookupall( -- builds a text array containing one item for every record in the target database where the data in the keyField matches the keyData. Each item in the text array contains the value extracted from the dataField for that record. If the data field is a numeric or date field, it is converted to text using the default patterns for that field.
- lookupalldouble( -- is similar to the lookupall( function, but it returns two fields from the target database instead of just one.
- lookupalloctet( -- is similar to the lookupall( function, but it returns eight fields from the target database instead of just one.
- lookupallquadruple( -- is similar to the lookupall( function, but it returns four fields from the target database instead of just one.
- lookupallquintuplet( -- is similar to the lookupall( function, but it returns five fields from the target database instead of just one.
- lookupallseptuplet( -- is similar to the lookupall( function, but it returns seven fields from the target database instead of just one.
- lookupallsextet( -- is similar to the lookupall( function, but it returns six fields from the target database instead of just one.
- lookupalltriple( -- is similar to the lookupall( function, but it returns three fields from the target database instead of just one.
- lookuplast( -- searches the selected records in a database for a value, then returns other information from the same record. For example, the *lookuplast(* function can look up a phone number given a customer name, or look up a price given a part number. Unlike the lookup( function which searches from the top of the database, the *lookuplast(* function searches backwards from the bottom.
- lookuplastselected( -- searches the selected records in a database for a value, then returns other information from the same record. For example, the *lookuplastselected(* function can look up a phone number given a customer name, or look up a price given a part number. Unlike the lookupselected( function which searches from the top of the database, the *lookuplastselected(* function searches backwards from the bottom.
- lookupmoredata( -- looks up an additional data field based on the previous lookup.
- lookupmoreformula( -- looks up additional data based on a previous lookup.
- lookupselected( -- searches the selected records in a database for a value, then returns other information from the same record. For example, the *lookupselected(* function can look up a phone number given a customer name, or look up a price given a part number.
- related( -- searches for a record in a related database that matches the current record in the current database based on a relational specification (based on one or more key fields or formulas in each database), then uses a formula to return other information from the same record. This is similar to the lookup( function, but instead of using an individual field for the key, a relation is used (see Relational Database Management).
- relatedarray( -- builds an Text Array by scanning a database and creating an array element for every record that matches a relational specification (based on one or more key fields or formulas). This is similar to the arraybuild( function, but instead of using an individual field for the key, a relation is used (see Relational Database Management).
- relatedrecordid( -- returns the record id of a record in a related database that matches the current record in the current database based on a relational specification.
- Relational Workshop -- tool that assists in composing relational lookup(, superlookup(, lookupall( and arraybuild( functions.
- serverlookup( -- searches a shared database for a value, then returns other information from the same record. Similar to the lookup( function, but the search is performed on the server instead in the local computer's memory.
- superlookup( -- searches a database for a record that matches a query formula, then uses a second formula to return other information from the same record. This is similar to the lookup( function, but instead of using an individual field for the key and data, any valid true/false (Boolean) formula can be used.
- table( -- searches a database for a value, then returns other information from the same record. Unlike the lookup( function, the *table(* function does not require an exact match. If it does not find an exact match the *table(* function will use the closest match. For example, the *table(* function can look up a tax rate given an income amount, or look up a shipping price given a zip code and weight.

History

Version | Status | Notes
10.0 | Updated | Carried over from Panorama 6.0, but now allows the first parameter to be omitted (defaults to current database), and allows the field to be specified by number (1, 2, 3 etc.) in addition to by name. Also, you can now use fieldvalue( instead of grabdata(, they are the same.