VarRecord GetFieldValue() Method

Gets the value of a field in the calling record's variable field list.

Function Signature

 bool GetFieldValue( name, string& value [, Variant& fieldList [, Variant& field] ])

bool GetFieldValue( name, int& value [, Variant& fieldList [, Variant& field] ])

bool GetFieldValue( name, int64_t& value [, Variant& fieldList [, Variant& field] ])

bool GetFieldValue( name, double& value [, Variant& fieldList [, Variant& field] ])

bool GetFieldValue( name, TimeT& value [, Variant& fieldList [, Variant& field] ])

bool GetFieldValue( name, Variant& value [, Variant& fieldList [, Variant& field] ])

Parameters

Parameter Type Description

name

string

The name of the field whose value will be retrieved from the calling record's variable field list.

Field names for variable fields should be provided in upper case for database names (TITLE, for example) or in lower/mixed-case for display names (Title, for example). For details on working with different types of database fields, refer to Working with SBM Database Fields.

value

string&

int&

int64_t&

double&

TimeT&

Variant&

(Output) The internal value for the field. For Text fields, this is the exact value entered in the field. For values that are not Variant or TimeT, this internally gets the value from the field as a Variant, and then tries to convert the value to the requested type.

TimeT can be used with Date/Time fields to get the internal date value.

Note: If the field is a Multi-User field for which the Groups and Users selection mode is enabled, the value can include both pure integers (TS_IDs from the TS_USERS table) and group identifiers (TS_IDs from the TS_GROUPS table). The latter are in the form G1, G2, …

fieldList

Variant&

(Output) Optional. If supplied and equal to the global constant Nothing, this parameter will refer to the calling record's VarFieldList when this method returns. If supplied and not equal to Nothing, this parameter is taken to be the calling record's VarFieldList.

Do not set this parameter's value yourself. Always pass a variable set to Nothing and then reuse the variable for subsequent calls to GetFieldValue() and SetFieldValue() on the same VarRecord object. If this parameter is omitted, no functionality changes, but efficiency may suffer.

field

Variant&

(Output) Optional. If supplied and equal to the global constant Nothing, this parameter will refer to the Field object on the calling record's VarFieldList whose name matches the name input parameter when this method returns. If supplied and not equal to Nothing, this parameter is taken to be that Field object.

As with the fieldList parameter, you should never set this value yourself. Always pass a variable equal to Nothing and reuse the variable in subsequent calls to GetFieldValue() and SetFieldValue() on the same VarRecord object and the same value for the name input parameter. Passing this parameter only affects the efficiency of repeated GetFieldValue() and SetFieldValue() calls.

Return

Type Description
bool True if the named field was found in the calling record's VarFieldList and its value was successfully retrieved.

Technical Details

SBM ModScript version: 11.3. Signatures where value is not Variant& were added in 11.4.

Example

var value = ""; // initialize value as a string
var fieldList = Variant();
var field = Variant();
fieldList = Nothing;
field = Nothing;
//  Create and retrieve Contact record
var myRecord = Ext.CreateAppRecord (Ext.TableId ("TS_CONTACTS"));
var ok = myRecord.ReadWithWhere ("TS_CONTACTFIRSTNAME = 'Joe'");
//  If no e-mail address, supply default value
if ( ok ) {
    ok = myRecord.GetFieldValue ( "EMAIL", value, fieldList, field);
}
if ( ok && value == "" ) {
    ok = myRecord.SetFieldValue ( "EMAIL", "joe@company.com", fieldList, field);
}
if ( !ok ) {
    Ext.LogErrorMsg ("Error in Joe's email field");
}

Notes

The fieldList and field parameters are optional. If supplied, they can boost efficiency for repeated calls to GetFieldValue() and SetFieldValue(). Note that fields not contained in a variable field list (i.e., system table fields) cannot be accessed with this method.

Also see VarRecord GetFieldValue-type-() Method.

Note: A GetFieldValue method is also included in the SBM JavaScript Library.

Related Topics

VarRecord