NetSuite Script Pattern to Pass Parameters to Map Reduce Functions

This article is relevant if you are seeking to learn how to pass a script parameter to a NetSuite Map / Reduce function.


A member of the NetSuite community reached out to me with the following question:

“Marty, I am looking for assistance and I hope you can assist me, I have asked support but they as is fairly typical cannot help me. I am working with a Map/Reduce script and I need to pass the ID of a saved search into the script. I am able to do this with a script parameter, if I set the parameter manually through the user interface. What I need now is to know how do I set a script parameter or a script from a different script? Any thoughts?”

How to Set the Map Reduce Script Parameter in SuiteScript 2.0

In response to the question, I reached out to one of our consultants that was recently working with the pattern. Here is his response:

“Here are the steps for passing a value to a Map/Reduce’ script parameter:

1. Create a script parameter in Map/Reduce script record through the UI.(i.e. custscript_pri_searchid)

2. In a different script, pass in the value(INTSEARCHID) when calling this Map/Reduce script.

Here is some sample code:

var objTask = task.create({taskType: task.TaskType.MAP_REDUCE});
objTask.scriptId = 'customscript_**';
objTask.deploymentId = 'custdeploy_**';
objTask.params = {custscript_pri_searchid : INTSEARCHID };

Let’s Get More Out of the NetSuite Platform

Back in 2008, one of the major reasons I made an investment to move my firm to produce and deliver NetSuite integration services, was due to the customization Platform. This is the place we can invent to leverage the coherent built-in transaction model while we can innovate to take care our clients’ concerns. If you too, as I do, love the NetSuite platform, let’s have a conversation.

Be Sociable, Share!

Marty Zigman

Holding all three official certifications, Marty is Southern California's NetSuite expert and leads a team of senior professionals at Prolecto Resources, Inc. He is a former Deloitte & Touche CPA and has held CTO roles. For over 25 years, Marty has produced leadership in ERP, CRM and eCommerce business systems. Contact Marty to set up a conversation.

More Posts - Website - Twitter - Facebook - LinkedIn - Google Plus - YouTube

| Category: NetSuite, Technical | Leave a comment

Post a Comment

Your email is never published nor shared. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>