2

I am very new to SuiteScript so I might be posting a lot of questions out here and hope you can all help.

My first question is why is my saved search not passing values on my MapReduce script? My code is below.

function getInputData() {
        try{
            log.debug("Get Input", "Initiated");
            //Customer Search
            var customerSearch = search.load({
                id: 'customsearch_brad_itemprice'
            });

            log.debug("customerSearch", customerSearch);
            log.debug("GetInputData", "Completed");

            return [customerSearch];
        }catch(exception){
            log.debug("GetInputDate Error Message:",exception);
        }
    }

Here is an image of the debug log that shows the variables are null.

Suitescript 2.0 Debug Log:

enter image description here

Your insights are greatly appreciated!

Brad

Brad D.
  • 47
  • 1
  • 8
  • 1
    Welcome to the SuiteScript community! Here are some resources to get you started: 1) Free NetSuite Professionals Slack community: http://netsuiteprofessionals.com/ 2) Stack Overflow Docs section: https://stackoverflow.com/documentation/netsuite/topics 3) Free email course with more great resources: http://learnsuitescript.com/ – erictgrubaugh Jun 25 '17 at 15:04

2 Answers2

3

You are returning an array of searches. You need to return a search object

Change this:

return [customerSearch];

to this:

return customerSearch;
Adolfo Garza
  • 2,966
  • 12
  • 15
0

getInputData function natively destructures the Array & Objects. each element can be received on the Map or Reduce function as below.

var elment = JSON.parse(context.value)