The N/action module APIs let you execute business logic to update the state of records in view mode. To execute business logic on records that you are editing, use the record macro APIs, which are included in the N/record Module module. See Record Object Members and Macro Object Members. Action and Macro APIs are the programmatic equivalent to clicking a button in the UI. To learn more, see Overview of Record Action and Macro APIs.
The changes that you make to records with N/action module APIs are persisted in the database immediately. For example, consider the timebill record. After you click the Approve button in the UI, the timebill and its entries are saved in an approved state, and this change is immediately updated in the database.
Governance for action module APIs varies for actions and record types. See the action help for governance information specific to actions and record types.
A limited number of individual actions for specific record types are supported. For details, see Supported Record Actions.
N/action Module Members
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Object |
Object |
Client and server scripts |
Encapsulates a NetSuite record action. |
|
Plain JavaScript Object |
Object |
Client and server scripts |
A plain JavaScript object of actions available for a record type. |
|
Method |
Object |
Client and server scripts |
Executes the record action and returns action results in an object. |
|
Promise |
Client scripts |
Asynchronously executes the record action and returns the action results in an object. |
||
string |
Client and server scripts |
Executes an asynchronous bulk record action and returns its task ID for later status inquiry. |
||
Object |
Client and server scripts |
Returns a plain JavaScript object of available record actions for the given record type. |
||
Promise |
Client scripts |
Asynchronously returns a plain JavaScript object of available record actions for the given record type. |
||
Client and server scripts |
Returns an executable record action for the given record type. |
|||
Promise |
Client scripts |
Asynchronously returns an executable record action for the given record type. |
Action Object Members
The following members are called on action.Action.
Member Type |
Name |
Return Type/Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Method |
Object |
Client and server scripts |
Executes the action and returns the action results in an object. |
|
Promise |
Client scripts |
Executes the action asynchronously and returns the action results in an object. |
||
Object |
Client and server scripts |
Executes the action and returns the action results in an object. |
||
Promise |
Client scripts |
Executes the action asynchronously and returns the action results in an object. |
||
string |
Client and server scripts |
Executes an asynchronous bulk record action and returns its task ID for later status inquiry. |
||
Object |
Client and server scripts |
Returns the current status of action.executeBulk(options) with the given task ID. |
||
Property |
string |
Client and server scripts |
The action description. |
|
string |
Client and server scripts |
The ID of the action. For a list of action IDs, see Supported Record Actions. |
||
string |
Client and server scripts |
The action label. |
||
Object |
Client and server scripts |
The action parameters. |
||
string |
Client and server scripts |
The type of the record on which the action is to be performed. For a list of record types, see record.Type. |
N/action Module Script Samples
These samples use the require
function, so that you can copy each script into the debugger and test it. Keep in mind that you must use the define
function in your entry point script (the script you attach to a script record). For more information, see SuiteScript 2.x Global Objects and SuiteScript 2.x Script Types.
The samples included in this section are intended to show how actions work in SuiteScript at a high-level. For specific samples, see Supported Record Actions.
This sample script uses the require
function so that you can copy it into the SuiteScript Debugger and test it. You must use the define
function in an entry point script (the script you attach to a script record and deploy). For more information, see SuiteScript 2.x Script Basics and SuiteScript 2.x Script Types.
The following server script sample finds and executes an action on the timebill record without promises.
This sample script uses the require
function so that you can copy it into the SuiteScript Debugger and test it. You must use the define
function in an entry point script (the script you attach to a script record and deploy). For more information, see SuiteScript 2.x Script Basics and SuiteScript 2.x Script Types.
The following client script sample asynchronously finds actions available for a timebill record and then executes one with promises.
This sample script uses the require
function so that you can copy it into the SuiteScript Debugger and test it. You must use the define
function in an entry point script (the script you attach to a script record and deploy). For more information, see SuiteScript 2.x Script Basics and SuiteScript 2.x Script Types.
The following sample shows how to execute a bulk approve action on a timebill record using different parameters.