SuiteScript / JavaScript Array Indexing Issues -


i working on dynamically generating xml printing labels. have array of values generated map, format of array should end such:

[[val1a, val1b, val1c],[val2a,val2b,val2c],[val3a,val3b,val3c]] 

i unable log browser console in application, must use provided logging apis view actual values of array @ given point. format presented logging such:

val1a,val1b,val1c,val2a... 

the values generated so:

for(var = 0; < lines; i++) {      for(var j = 0; j < quantity; j++){         smcnts.push([i]);     } } 

where i line number of specific "record", , j iterating on quantity, pushing line number array smcnts. resulting in dataset (assuming line 1 has quantity of 3, , line 2 has quantity of 2 etc.):

[[1], [1], [1], [2], [2], [3]] 

this array mapped using function gets values lines:

var smlbls = smcnts.map(getdata); 

resulting in first array listed in question.

the problem results when trying index array specific value:

var foo = smlbls[1]; 

this returns nothing, don't know if returns null logging api returns only: .

however, logging smlbls returns first mentioned array described in second code snippet. causing issue? need able index of index of array so:

var bar = smlbls[1][3]; 

everything else working expected, unable access data whatever reason, maybe not understanding javascript fully?

i unable log browser console in application, must use provided logging apis view actual values of array @ given point. format presented logging such:

my advice, use logs extract snapshot of data:

nlapilogexecution('debug', 'sample', json.stringify(data));  

...and work in browser.


Comments