Hi , I am using Map/Reduce Script - In Get Input -...
# suitescript
n
Hi , I am using Map/Reduce Script - In Get Input -returning the saved search results I am not using Map Reduce - By using JSON.parse(context.values[0]) - I am getting the Saved search results in array Is there any other way to get the data from the get input in reduce? @ThanksInAdvance
b
that is the primary way to get an object out of reduce
usually with a loop for all the values
n
context.values[0] - can i know what it does?
If I use JSON.parse(context.values) i ma getting the unexpected token error
b
as in you dont know how object keys work?
or you dont understand the structure of context?
n
I am aware of the structure,i kept logs for that and i am getting all the results in an array
b
context.values is an array
n
context.values[0] - is the index of the context?
b
you access the contents of an array using indexes
using the syntax you are pasting
specifically, context.values[0] returns the first element of context.values
n
In Map - we can get the data by using JSON.parse(context.value) where we will not loop the data. Can we do the same in reduce?
b
the structure of the context of a map is different than that from a reduce
n
ok thanks @battk
In reduce - I am using Json.parse(context.values[0]) it will return an entire array - Can I get the data in a single array and process the records?
b
parse each element and put it in a new array
n
Can I get the data in a single array and process the records in reduce from the getinput?
b
If you are asking if you can make reduce act like map, the answer is no