SuiteScript 2.x Record Actions and Macros for Automation
SuiteScript 2.x introduces APIs for automating record actions and macros, enhancing productivity by replicating UI button functions programmatically.
SuiteScript 2.x supports APIs that provide the programmatic equivalent of clicking a button in the NetSuite user interface. The record action and macro APIs allow developers to run the same business logic as a UI button click. This capability can significantly enhance productivity by automating routine tasks previously requiring manual interaction in the UI.
How Do Record Actions and Macros Work?
NetSuite records offer two methods for executing native logic: either through direct UI interaction or by running scripts that utilize the corresponding API for the action. Both approaches yield the same results, but utilizing SuiteScript's macro and action APIs can simplify scripting and enhance flexibility.
Record Actions
Record actions allow for the convenient updating of one or more records currently in view mode. The changes made by these actions are immediately saved in the database without needing to check for required roles or permissions, since the necessary conditions for execution are pre-embedded in the action API. This characteristic allows for efficient handling of multiple records, such as approval or rejection actions. For example, when an approve action is executed on a record, the approval status is instantly recorded.
Record Macros
Conversely, record macros automate the execution of business logic during the editing of a record. Unlike record actions, changes made through a macro are not saved until the record itself is saved. For instance, a macro can provide a preview of the calculated tax amount for items in a sales order after entering details, but this information is not finalized until the user saves the record.
Benefits of Using Record Actions and Macros
- Reduced Governance Usage: By executing complex business logic via a single API call, you minimize governance charges compared to multiple API calls associated with traditional logic execution methods.
- Automation of Complexity: Handle intricate processes effortlessly without manually navigating UI elements.
- Flexibility: Apply the same logic consistently across various scripting contexts, making wider applicability achievable.
Supported Record Macros
Macros are categorized by record type, each with its UI button labels. Here’s a list of currently supported record macros:
| Record Type | Macro ID | UI Button Label |
|---|---|---|
| Billing Rate Card | modifyPriceByPercent | Recalculate |
| Project Charge Rule | copyResources | Copy Resources from Tasks |
| Project Work Breakdown Structure | getAmountFieldValue | Get Amount Field Value |
| Project Work Breakdown Structure | getAmountsFields | Get Amounts Fields |
| Project Work Breakdown Structure | getUnmatchedActuals | Get Unmatched Actuals |
| Project Work Breakdown Structure | setAmountFieldValue | Set Amount Field Value |
| Sales Order | autoAssignLocations | Auto Assign Locations |
| Transaction Record | calculateTax | Preview Tax |
| Transaction Record | getSummaryTaxTotals | Get Summary Tax Totals |
With these APIs, SuiteScript 2.x empowers developers to create more efficient and automated solutions, further enhancing the capabilities of the NetSuite platform.
Frequently Asked Questions (4)
Do record actions in SuiteScript 2.x require checking for user roles or permissions?
When using record macros in SuiteScript 2.x, are changes immediately saved to the database?
Which SuiteScript 2.x feature allows for the automation of business logic during record editing?
Does using SuiteScript 2.x record actions and macros reduce governance charges?
Was this article helpful?
More in SuiteScript
- SuiteScript 2.1 Enhancements in NetSuite February Updates
SuiteScript 2.1 now supports async features and PATCH method. Discover the latest API and SuiteProcurement improvements.
- Scheduling Map/Reduce Script Deployments in NetSuite
Learn to schedule map/reduce script submissions, including one-time and recurring options in NetSuite.
- Binary File Support in N/https Module for SuiteScript
SuiteScript enhances capabilities with binary file support in the N/https module, allowing improved data handling in external communications.
- API Governance Units Calculation in NetSuite 2026.1
NetSuite 2026.1 introduces examples illustrating API governance unit calculations for both user event and scheduled scripts.
