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.

·3 min read·View Oracle Docs

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 TypeNameReturn Type / Value TypeSupported Script TypesDescription
Objectaction.ActionObjectClient and server scriptsEncapsulates a NetSuite record action.
Plain ObjectObjectObjectClient and server scriptsA plain JavaScript object of actions available for a record type.
Methodaction.execute(options)ObjectClient and server scriptsExecutes the record action and returns results.
Methodaction.execute.promise(options)PromiseClient scriptsExecutes the record action asynchronously.
Methodaction.executeBulk(options)stringClient and server scriptsExecutes a bulk record action asynchronously.
Methodaction.find(options)ObjectClient and server scriptsReturns available record actions for the record type.
Methodaction.get(options)action.ActionClient and server scriptsReturns 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 TypeNameReturn Type/Value TypeSupported Script TypesDescription
MethodAction(options)ObjectClient and server scriptsExecutes the action with results returned.
MethodAction.promise(options)PromiseClient scriptsExecutes the action asynchronously.
MethodAction.execute(options)ObjectClient and server scriptsDirect action execution with results returned.
MethodAction.executeBulk(options)stringClient and server scriptsExecutes 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?
No, the N/action module is specifically designed for executing actions on records in view mode. For records in edit mode, you should use the N/record module's macro APIs.
Are changes made using the N/action module immediately updated in the database?
Yes, changes made using the N/action module are persisted to the database instantaneously, reflecting real-time feedback similar to actions performed directly in the NetSuite UI.
Is there a governance limit for actions executed through the N/action module?
Yes, each action in the N/action module is subject to governance limits, which can vary depending on the record type and the action being executed. Reviewing the governance documentation for the specific action type is recommended.
Can all record actions be automated using the N/action module?
No, not all record actions are supported across all record types. Developers should refer to the documentation on Supported Record Actions to determine compatibility with the N/action APIs.
Source: N/action Module Members Oracle NetSuite Help Center. This article was generated from official Oracle documentation and enriched with additional context and best practices.

Was this article helpful?

More in Platform

View all Platform articles →