Very often, when working with SuiteScript, a developer will be tasked to write a map-reduce script that updates all of the NetSuite records that their user event script is already updating. If this is the case, a minimal map/reduce script can be written to put all the work on the user event script. This method also has the benefit of decreasing the amount of code that may have to be reworked to just the user event script.
Step 1: Check that your user event script is set to trigger on the map/reduce context.
Step 2: In the getInputData stage of your map reduce, return a search for the NetSuite records you wish to update in the map reduce. Below is an example:
Step 3: In the reduce script, load and save your NetSuite record, triggering the user event script on record save. Use the reduce context’s key to get the NetSuite record’s internal ID, and do not forget to put everything around a try/catch block to catch errors that may occur. Here is an example of how the reduce code would look:
We like to update our blogs and articles to make sure they help resolve any troubleshooting difficulties you are having. Sometimes, there is a related feature to enable or a field to fill out that we miss during the instructions. If this article didn't resolve the issue, please use the chat and let us know so that we can update this article!
If you have questions about how our team can support your business as you implement NetSuite or SuiteCommerce, feel free to contact us anytime. Anchor Group is a certified Oracle NetSuite Alliance Partner and Commerce Partner equipped to handle all kinds of NetSuite and SuiteCommerce projects, large or small!
Tagged with Training