Record.getText(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

Method Description

Returns the text representation of a field value.

(dynamic and standard mode — see SuiteScript 2.x Standard and Dynamic Modes)

Gets a string value with a "%" for rate and ratehighprecision fields.

Returns

string

Note:

For multiselect fields, returns an array.

Supported Script Types

Client and server scripts.

For more information, see SuiteScript 2.x Script Types.

In dynamic mode, you can use getText() without limitation but, in standard mode, limitations exist. In standard mode, you can use this method only in the following cases:

  • You can use getText() on any field where the script has already used setText().

  • If you are loading or copying a record, you can use getText on any field except those where the script has already changed the value by using setValue().

For more details, refer to the description of the SSS_INVALID_API_USAGE error code in the Errors table.

Governance

None

Module

N/record Module

Sibling Object Members

Record Object Members

Since

2015.2

Parameters
Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

Since

options.fieldId

string

required

The internal ID of a standard or custom body field.

See, How to Find a Field's Internal ID.

2015.2

Errors

Error Code

Thrown If

SSS_INVALID_API_USAGE

Invoked in certain cases when standard mode is being used.

For example, if Record.isDynamic is set to false, the SSS_INVALID_API_USAGE error can be invoked in the following situations:

  • If the record object was created by record.create() or record.transform(), and the script attempts to use getText() without first using setText() for the same field.

  • The record object was created by record.copy() or record.load(), and the script uses setValue() on a field before using getText() for the same field.

Similar guidance affects user event scripts that instantiate records by using the newRecord or oldRecord object provided by the script context. In these cases, standard mode is always used. For that reason, the SSS_INVALID_API_USAGE error appears when a user event executes on one of these objects in the following situations:

  • When the script executes on a record that is being created, and the script attempts to use getText() without first using setText() for the same field.

  • When the script executes on an existing record or on a record being created through copying, and the script uses setValue() on a field before using getText() for the same field.

SSS_MISSING_REQD_ARGUMENT

A required argument is missing or undefined.

Syntax
Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/record Module Script Samples.

          // Synax Sample 1
// Add additional code
...
var fieldidname = objRecord.getText({
    fieldId: 'item'
});
...
// Add additional code

// Syntax Sample 2
// Add additional code
...
myString = 'Date is: ' + record.getText({fieldId: 'datechanged'});
// "Date is: 3/27/2017 9:55:38am"
...
// Add additional code 

        

Related Topics

record.Record
N/record Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices