SBM ModScript Reference → Programming SBM ModScript → Object Types → VarRecord → VarRecord SetFieldValue() Method
(SBM On-Premise/PaaS only) Sets the value of a field in the calling record's VarFieldList.
bool SetFieldValue( name, string& value [, Variant& fieldList, Variant& field ]) bool SetFieldValue( name, int& value [, Variant& fieldList, Variant& field ]) bool SetFieldValue( name, int64_t& value [, Variant& fieldList, Variant& field ]) bool SetFieldValue( name, double& value [, Variant& fieldList, Variant& field ]) bool SetFieldValue( name, TimeT& value [, Variant& fieldList, Variant& field ]) bool SetFieldValue( name, Variant& value [, Variant& fieldList, Variant& field ])
Parameter | Type | Description |
---|---|---|
name | string |
The name of the field whose value will be changed in 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& |
(Input/Output) A value in internal database format to be written to the named field in the calling record's VarFieldList. For values other than Variant and TimeT, value will be internally converted to Variant. TimeT can be used with Date/Time fields to set the internal date value. |
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. |
Type | Description |
---|---|
bool | True if the field was changed. |
SBM ModScript version: 11.3. Signatures where value is not Variant& were added in 11.4.
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 like '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"); }
This SetFieldValue() method specifically relates to VarRecords that are used for auxiliary and primary table records. For system table records, see AppRecord SetFieldValue() Method.
If the field is a journal field, consider using Field.AppendJournalText() to add a single journal entry.
"00:00:" & elapsedTimeSBM converts the seconds into the correct hours, minutes, and seconds for you.
Copyright © 2007–2019 Micro Focus or one of its affiliates. All rights reserved.