recordContext.getContext(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

Method Description

Returns the record context object for a given record.

The parameters you specify for this method depend on whether the record is currently loaded in your script:

  • For records that are not loaded in your script, the record is defined by record type and ID. In this case, you must use the recordType and recordId parameters to specify the record to obtain the context for. You do not use the record parameter.

  • For records that are loaded in your script, the record is defined by the record object. In this case, you must use the record parameter to specify the record to obtain the context for. You do not use the recordType and recordId parameters.

Returns

recordContext.RecordContext

Supported Script Types

Client and server scripts

Governance

10 units

Module

N/recordContext Module

Since

2020.2

Parameters

Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

Since

options.recordType

string

required if the record is not loaded in your script

The record type.

2020.2

options.recordId

string

required if the record is not loaded in your script

The internal ID of the record.

2020.2

options.record

record.Record

required if the record is loaded in your script

The record object.

2020.2

options.contextTypes

Array<string>

optional

The context type to retrieve. See recordContext.ContextType.

2020.2

Errors

Error Code

Thrown If

MUTUALY_EXCLUSIVE_ARGUMENT

The record is present alongside a record ID or record type.

MISSING_REQD_ARGUMENT

Any of the record ID or record type parameter is missing.

SSS_INVALID_TYPE_ARG

The parameter type is wrong.

UNKNOWN_CONTEXT_TYPE

The context type selection is unknown.

INVALID_UNSUPRTD_RCRD_TYP

The record type selection is invalid or not supported.

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/recordContext Module Sample.

            // Add additional code 
// Sample code on getting context for records that are not loaded
...
var employeeContext = recordContext.getContext({
            recordType: record.Type.EMPLOYEE,
            recordId: employeeId
            contextTypes: [recordContext.ContextType.LOCALIZATION]
...
// Add additional code 

          
            // Add additional code 
// Sample code on getting context for records that are loaded
...
var lrc = recordContext.getContext({
    record: recordObject,
    contextTypes: [recordContext.ContextType.LOCALIZATION]
...
// Add additional code 

          

Related Topics

N/recordContext Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices