SuiteScript 2.x Map/Reduce Script Type
The map/reduce script type is designed for scripts that need to handle large amounts of data. It's best for situations where you can divide the data into small, independent parts. When the script is executed, a structured framework automatically creates enough jobs to process all of these parts. You do not have to manage this process; NetSuite does it all for you. Another advantage of map/reduce is that these jobs can work in parallel and you can choose the level of parallelism when you deploy the script.
A map/reduce script can be run manually or on a schedule, like a scheduled script. Map/reduce scripts have several advantages over scheduled scripts. One advantage is that, if a map/reduce job violates certain aspects of NetSuite governance, the map/reduce framework automatically causes the job to yield and its work to be rescheduled, without disruption to the script. However, be aware that some aspects of map/reduce governance can't be handled through automatic yielding. For that reason, if you use this script type, you should familiarize yourself with the Map/Reduce Governance guidelines.
In general, use a map/reduce script when you need to process multiple records and can break your logic into smaller pieces. In contrast, a map/reduce script isn't as well suited to situations where you want to enact a long, complex function for each part of your data set. A complex series of steps might include loading and saving multiple records.
You can use SuiteCloud Development Framework (SDF) to manage map/reduce scripts as part of file-based customization projects. For information about SDF, see SuiteCloud Development Framework. You can use the Copy to Account feature to copy an individual map/reduce script to another of your accounts. Each map/reduce script page has a clickable Copy to Account option in the upper right corner. For information about Copy to Account, see Copy to Account.
You can use SuiteScript Analysis to learn about when the script was installed and how it performed in the past. For more information, see Analyzing Scripts.
For more information about map/reduce scripts, see the following topics:
Also see the Map/Reduce Script Best Practices section in the SuiteScript Developer Guide for a list of best practices to follow when using client scripts.
Map/Reduce Script Use Cases
Map/reduce scripts are perfect for applying the same logic to multiple objects, one at a time. For instance, you can use map/reduce scripts for tasks like:
-
Identify a list of purchase requisitions and transform each one into a purchase order.
-
Search for invoices that meet certain criteria and apply a discount to each one.
-
Search for customer records that appear to be duplicates, then process each apparent duplicate according to your business rules.
-
Search for outstanding tasks assigned to sales reps, then send each person an email that summarizes their outstanding work.
-
Identify files in the NetSuite File Cabinet, use the content of the files to create new documents, and upload the new documents to an external server.
Related Support Article
Related Topics
- SuiteScript Versioning Guidelines
- SuiteScript 2.1
- SuiteScript 2.x Script Types
- SuiteScript 2.x Bundle Installation Script Type
- SuiteScript 2.x Client Script Type
- SuiteScript 2.x Mass Update Script Type
- SuiteScript 2.x Portlet Script Type
- SuiteScript 2.x RESTlet Script Type
- SuiteScript 2.x Scheduled Script Type
- SuiteScript 2.x Suitelet Script Type
- SuiteScript 2.x User Event Script Type
- SuiteScript 2.x Workflow Action Script Type