User.getPreference(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

Method Description

Returns the value set for a NetSuite preference.

Currently only General Preferences and Accounting Preferences are exposed in SuiteScript.

You can also view General Preferences by going to Setup > Company > General Preferences. View Accounting Preferences by going to Setup > Accounting > Accounting Preferences.

If you want to change the value of a General or Accounting preference using SuiteScript 2.0, you must load each preference page using config.load(options), where options.name is COMPANY_PREFERENCES or ACCOUNTING_PREFERENCES. The config.load(options) method returns a record.Record. You can use the Record.setValue(options) method to set the preference.

For more information about these preferences, see General Preferences and Accounting Preferences.

Note:

The permission level will be Permission.FULL if the script is configured to execute as administrator. You can configure a script to execute as admininistrator by selecting “administrator” from the Execute as Role field on Script Deployment page.

Returns

string

Supported Script Types

Client and server scripts

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

Governance

None

Module

N/runtime Module

Since

2015.2

Parameters
Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

Since

options.name

string

required

Internal ID of the preference. For a list of preference IDs, see Preference Names and IDs.

2015.2

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/runtime Module Script Samples.

          // Add additional code 
...
var userObj = runtime.getCurrentUser();
var userPref = userObj.getPreference ({
    name: 'emailemployeeonapproval'
});
log.debug('User preference for emailemployeeonapproval: ' + userPref);
...
// Add additional code 

        

Related Topics

runtime.User
N/runtime Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices