Custom Tool Script for Number Addition and String Reversal in
Starting in NetSuite 2026.1, a new custom tool script enables addition of numbers and reversal of strings using SuiteScript 2.1.
Starting in NetSuite 2026.1, a new custom tool script is introduced that allows developers to implement functionality for adding two numbers and reversing a string. This enhancement is especially useful for developers looking to create efficient scripts that execute multiple operations with minimal overhead.
Overview of the Custom Tool Script
The custom tool script sample consists of two primary functions:
- Addition: Adds two numbers provided as arguments.
- String Reversal: Reverses a string input.
This sample utilizes SuiteScript 2.1's define function, imperative for defining entry point scripts that can be deployed and attached to script records. This structure aligns with modern practices in NetSuite development, ensuring scripts are modular and re-usable.
Script Details
Here’s a breakdown of the script content:
1/**2 * exampletools.js3 * @NApiVersion 2.14 * @NModuleScope Public5 * @NScriptType CustomTool6 */7 8"text-purple-400">define([], "text-purple-400">function() {9 10"text-purple-400">return {11 12add: "text-purple-400">async "text-purple-400">function (args) {13 14"text-purple-400">try {15 16"text-purple-400">const a = args["a"];17 18"text-purple-400">const b = args["b"];19 20"text-purple-400">return {21result: a + b22};23 24} "text-purple-400">catch(e) {25"text-purple-400">return {26result: "",27error: "There was an error executing the tool: " + e28};29}30},31 32reverseText: "text-purple-400">async "text-purple-400">function (args) {33 34"text-purple-400">try {35 36"text-purple-400">const text = args["text"];37 38"text-purple-400">return {39result: text.split('').reverse().join('')40};41 42} "text-purple-400">catch(e) {43"text-purple-400">return {44result: "",45error: "There was an error executing the tool: " + e46};47}48}49 50}51});Important Notes
- Error Handling: Each method has robust error handling to ensure that potential issues do not disrupt the execution of the script. Developers should consider extending error messages to capture more context as necessary.
- Module Imports: Although the script does not import specific modules, it’s advisable to import modules like
N/logandN/utilwhen utilizing their functionalities. This practice ensures better management of dependencies and reduces issues related to module availability.
Who This Affects
This new feature is particularly relevant for:
- Developers: Who will implement and maintain custom scripts.
- Administrators: Overseeing the deployment and usage of these tools within the organization.
Key Takeaways
- The custom tool script for adding numbers and reversing strings is newly available in SuiteScript 2.1 starting from NetSuite 2026.1.
- It demonstrates the use of asynchronous functions and error handling in operation.
- Developers should always incorporate necessary module imports to enhance script reliability.
- Utilizing modern JavaScript features can improve script performance and readability.
Weekly Update History (1)
CustomTool is now supported in the @NScriptType JSdoc tag and must be included in the headers of Custom Tool scripts. Updated the information in the following help topics: SuiteScript 2.1 Custom Tool Script Type Code Samples SuiteScript 2.x JSDoc Tags Required JSDoc Tags for Entry Point Scripts
View Oracle DocsWas this article helpful?
More in SuiteScript
- N/https Module: Binary File Support in NetSuite 2025.2
NetSuite 2026.1 adds binary file support to N/https for streamlined file handling.
- 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.
- Attach and Detach Operations in NetSuite 2026.1
Attach and detach operations for record relationships in NetSuite enhance data management and connectivity.
- Create-Form Operation in NetSuite 2026.1 REST Web Services
Create-form operation in NetSuite 2026.1 APIs streamlines record creation and enhances efficiency.
Also from NetSuite 2026.1
- Custom Labels for Additional Item Prices in NetSuite 2026.1
Custom labels enhance transaction summaries in NetSuite, improving clarity for item prices.
- Applied Trans Date and Period Enhancements in NetSuite 20...
Latest updates in NetSuite 2024.1 enhance Accounting SuiteApps with transaction line distribution features.
- Data Not Copied from Production to Sandbox in NetSuite 2026.1
In NetSuite 2026.1, key data like domains and customer roles are not copied to sandbox accounts during refreshes, impacting setup.
- Available Items Only Feature in NetSuite 2026.1
Available items only filtering boosts sales efficiency in NetSuite 2026.1 with Intelligent Item Recommendations.
Advertising
Reach SuiteScript Professionals
Put your product in front of NetSuite experts who work with SuiteScript every day.
Sponsor This Category