javascript - How to access the data's(search,objects) returned by the getInputMethod on Map Method of Map Reduce Script in Netsuite -


in getinputdata() of map reduce script , created search on invoice record , created search on custom record called contract , stored results in 1 object , have created search on custom record called formula , stored results in 1 object returning invoice search results, contract object , formula object.

i data's returned on getinputdata method accessed on map method using context object.

i'm getting data of invoice search results on map method using json.parse(context.value); how data of contract object , formula object on map method.

code:

var  contractrecords = {};  var formulas = {};  define(['n/error', 'n/record', 'n/search', 'n/log', 'n/task', 'n/runtime', 'n/email'],  function(error, record, search, log, task, runtime, email) {  function getinputdata() {                 try{                 log.debug("get input", "initiated");                 //invoice search                 var invoicesearch = search.load({                     id: 'customsearch_invoice_search'                 });                  log.debug("invoicesearch:", invoicesearch);                 log.debug("getinputdata", "completed");                 //storing values on contract object creating search on contract record                 contractrecords = loadcontractrecords();                 log.debug("contractrecords:",contractrecords);                   //storing values on formula object creating search on formula record                 formulas = loadformulas();                 log.debug("formulas:",formulas);                  return [invoicesearch,contractrecords,formulas];                 }catch(exception){                     log.debug("getinputdate error message:",exception);                 }             }               function map(context) {                 try{                 //getting search results of invoice                 var searchresult = json.parse(context.value);                 log.debug("searchresult:", searchresult);                 var invoiceid = searchresult.id;                 var item = searchresult.values.item.value;                 var lineid = searchresult.values.line;                 var lineuniquekey = searchresult.values.lineuniquekey.value;                 var invoice_amt = searchresult.values.amount;                  }catch(exception){                   log.debug("map error message:",exception);                 }                 }                   function reduce(context) {                    log.debug("reduce:", "initiated");                  }                   function summarize(summary) {                    log.debug("summarize", "initiated");                    log.debug("summarize", "completed");                }                  return {                 getinputdata: getinputdata,                 map: map,                 reduce: reduce,                 summarize: summarize             };          }); 

the contractrecords ,formulas objects global, have assigned objects methods returning objects , have accessed global variables on map() method returning empty values in getinputdata() method same object having values. returned contract , formula objects along invoice search results on return statement of getinputdata() method didn't able values of contract , formula object on map() method.

thanks in advance

the return of getinputdata() method should 1 of 4 value types (array | object | search.search | mapreduce.objectref). latter 2 search.search , mapreduce.objectref both have special handling. each of results of ran search sent map stage.

from example, returning array (containing 3 slots); spawn 3 different map stage processes. each of 3 map stage processes contain data of slot (invoicesearch, contractrecords, formulas) return of getinputdata().

do need data both contractrecords , formulas invoicesearch individual results during map stage?


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -