AppRecord GetFieldValue-type-() Method

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

Function Signature

 string GetFieldValueString( name )

int GetFieldValueInt( name )

int64_t GetFieldValueInt64( name )

double GetFieldValueDouble( name )

TimeT GetFieldValueTimeT( name )

Variant GetFieldValue( name )

Parameters

Parameter Type Description

name

string

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

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.

Return

Type Description

string

int

int64_t

double

TimeT

Variant

The internal value for the field. For Text fields, this is the exact value entered in the field.

Technical Details

SBM ModScript version: 11.3.

Signatures where return is not Variant were added in 11.4 and moved from VarRecord to AppRecord in 11.6.

Example

Example with AppRecord:

//Create and retrieve Project record
var tableId = Ext.TableId("TS_PROJECTS");
var myRecord = Ext.CreateAppRecord(tableId);
var ok = myRecord.Read("Image Builder");
if ( ok != 0 ) {
	 var value = myRecord.GetFieldValueInt( "parentid" ); 
	 Ext.LogInfoMsg ("Parent ID of Image Builder is " &&& value);
} 

Example with VarRecord:

//  Create and retrieve Contact record
var myRecord = Ext.CreateVarRecord (Ext.TableId ("TS_CONTACTS"));
var ok = myRecord.ReadWithWhere ("TS_CONTACTFIRSTNAME like 'Joe'");
//  If no e-mail address, supply default value
if ( ok ) {
    var value = myRecord.GetFieldValueString( "EMAIL" );
    if ( value == "" ) {
        ok = myRecord.SetFieldValue ( "EMAIL", "joe@company.com" );
    }
}
if ( !ok ) {
    Ext.LogErrorMsg ("Error in Joe's Email field");
}

Notes

Also see AppRecord GetFieldValue() Method.

Important: Only use this version of GetFieldValue() if you are sure that the field will be found. It is not recommended to use the Variant version of this method with dates; instead, use the GetFieldValueTimeT( name ) signature.

Related Topics

VarRecord