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
- Common SuiteScript Errors and Solutions for NetSuite
Common NetSuite script errors include INVALID_SCRIPT_DEPLOYMENT_ID and SSS_AUTHORIZATION_HEADER_NOT_ALLOWED. Learn effective solutions.
- Set Sublist Field Values in SuiteScript 2.x for Record Management
Set sublist field values in SuiteScript 2.x for effective record management using standard and dynamic modes.
- Setting Field Values in SuiteScript for Effective Record
Learn to set field values in SuiteScript effectively, troubleshooting common errors and understanding data types.
- SuiteScript 2.1 Enhancements and API Updates in NetSuite
SuiteScript 2.1 enables execution of 2.0 scripts and supports PATCH method for enhanced API capabilities.
Advertising
Reach SuiteScript Professionals
Put your product in front of NetSuite experts who work with SuiteScript every day.
Sponsor This Category