N/action Module for SuiteScript 2.x Record Actions
Utilize the N/action module in SuiteScript 2.x to manage record actions with immediate database updates and various execution methods.
The N/action module provides a way to execute business logic that updates record states while in view mode. It allows developers to simulate user interactions, such as clicking buttons, through programmatic means. This functionality is essential for automating workflows and ensuring data integrity in NetSuite applications.
What is the N/action Module?
The N/action module is designed specifically for executing actions on records that are currently displayed in view mode. If you need to manipulate records in edit mode, the N/record module's macro APIs are more suitable. Essentially, the action APIs serve as a programmatic equivalent of performing tasks manually in the NetSuite user interface.
Immediate Database Updates
When using the N/action APIs, changes to records are persisted to the database instantaneously. For example, approving a timebill through the API will immediately reflect this approved state within the database, mimicking the real-time feedback found in the UI.
Governance and Limitations
Each action in the N/action module has its governance limits that may vary depending on the record type and the actions being executed. Ensure to review the governance documentation related to the specific action type for more comprehensive guidance.
Supported Actions
Not all actions are supported across all record types. You can refer to the documentation regarding Supported Record Actions for insights into which record types are compatible with the N/action APIs.
N/action Module Members
Below is a summary of the members present within the N/action module:
| Member Type | Name | Return Type / Value Type | Supported Script Types | Description |
|---|---|---|---|---|
| Object | action.Action | Object | Client and server scripts | Encapsulates a NetSuite record action. |
| Plain Object | Object | Object | Client and server scripts | A plain JavaScript object of actions available for a record type. |
| Method | action.execute(options) | Object | Client and server scripts | Executes the record action and returns results. |
| Method | action.execute.promise(options) | Promise | Client scripts | Executes the record action asynchronously. |
| Method | action.executeBulk(options) | string | Client and server scripts | Executes a bulk record action asynchronously. |
| Method | action.find(options) | Object | Client and server scripts | Returns available record actions for the record type. |
| Method | action.get(options) | action.Action | Client and server scripts | Returns an executable record action for given record type. |
Action Object Members
In addition to the main N/action members, the following methods are part of the action object:
| Member Type | Name | Return Type/Value Type | Supported Script Types | Description |
|---|---|---|---|---|
| Method | Action(options) | Object | Client and server scripts | Executes the action with results returned. |
| Method | Action.promise(options) | Promise | Client scripts | Executes the action asynchronously. |
| Method | Action.execute(options) | Object | Client and server scripts | Direct action execution with results returned. |
| Method | Action.executeBulk(options) | string | Client and server scripts | Executes bulk action, returning task ID. |
Conclusion
The N/action module plays an essential role in SuiteScript development, especially for automating tasks that require record updates. Its immediate data persistence and various execution methods ensure efficient handling of business logic.
Source: This article is based on Oracle's official NetSuite documentation.
Key Takeaways
- N/action module allows executing record actions in view mode.
- Changes made are immediately reflected in the database.
- Governance for actions varies by record type.
- Limited actions are supported across different record types.
- Developers can programmatically simulate UI interactions.
Frequently Asked Questions (4)
Does the N/action module support executing actions in edit mode?
Are changes made using the N/action module immediately updated in the database?
Is there a governance limit for actions executed through the N/action module?
Can all record actions be automated using the N/action module?
Was this article helpful?
More in Platform
- Style Object Members for Workbook API in NetSuite
The Style object provides customizable properties for workbook formatting in NetSuite, enhancing report and visualization functionality.
- Asynchronous HTTP Requests with SuiteScript Promises
Use SuiteScript to send asynchronous HTTP requests with promises for efficient error handling and response processing.
- Setting Sublist Field Values in SuiteScript
Set values for sublist fields in SuiteScript using the setSublistValue method. Understand required parameters and error handling.
- In This Help Topic
Explore N/log module guidelines, log levels, and script execution logs for efficient logging in SuiteScript.
Advertising
Reach Platform Professionals
Put your product in front of NetSuite experts who work with Platform every day.
Sponsor This Category