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 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


History

VersionStatusNotes
10.0UpdatedCarried 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.