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.

·3 min read·View Oracle Docs

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 TypeMacro IDUI Button Label
Billing Rate CardmodifyPriceByPercentRecalculate
Project Charge RulecopyResourcesCopy Resources from Tasks
Project Work Breakdown StructuregetAmountFieldValueGet Amount Field Value
Project Work Breakdown StructuregetAmountsFieldsGet Amounts Fields
Project Work Breakdown StructuregetUnmatchedActualsGet Unmatched Actuals
Project Work Breakdown StructuresetAmountFieldValueSet Amount Field Value
Sales OrderautoAssignLocationsAuto Assign Locations
Transaction RecordcalculateTaxPreview Tax
Transaction RecordgetSummaryTaxTotalsGet 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.

Source: This article is based on Oracle's official NetSuite documentation.

Frequently Asked Questions (4)

Do record actions in SuiteScript 2.x require checking for user roles or permissions?
No, record actions do not require checking for user roles or permissions because the necessary conditions for execution are pre-embedded in the action API.
When using record macros in SuiteScript 2.x, are changes immediately saved to the database?
No, changes made through record macros are not saved until the record itself is saved. This allows for previewing certain logic, like tax calculations, before finalizing the transaction.
Which SuiteScript 2.x feature allows for the automation of business logic during record editing?
Record macros enable the automation of business logic during the editing of a record, offering a preview of values such as calculated taxes before saving.
Does using SuiteScript 2.x record actions and macros reduce governance charges?
Yes, executing complex business logic via a single API call with record actions and macros reduces governance usage compared to traditional methods involving multiple API calls.
Source: SuiteScript 2.x Record Actions and Macros 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 Integration

View all Integration articles →