Hello, in my `getInputData` phase of the map-reduc...
# suitescript
k
Hello, in my
getInputData
phase of the map-reduce function, I am getting the data as an array of objects like this:
Copy code
[{"invoiceid":"12345","custemail":"<mailto:testemail@gmail.com|testemail@gmail.com>"}, {"invoiceid":"67890","custemail":"<mailto:useremail@gmail.com|useremail@gmail.com>"}]
I am not able to extract these data either in the map or reduce stage, is there any massaging needed to this data before passing on to the next phase?
d
As far as I remember, if you want any data in reduce, it must be written in map phase, so you mustn't skip it.
c
You can skip the map phase.
All getInputData does is gather your data in an array to send to map or reduce. If you dont need any grouping, then you can go straight to reduce. JSON.parse your context values in reduce and you'll have your object.
k
Thank you for your response! With the above data, I am sending it to reduce phase as it is, and trying to extract it using JSON.parse(context.value), however, I am not getting anything. I am also not getting any value when I just log.debug(context) in the reduce stage.
e
Your JSON object is an array so you need to loop through it
for (var idx = 0; idx < context.values.length; idx++) {
var row = JSON.parse(context.values[idx]); }
n
Notice context.values not context.value
k
Thank you for the response guys! I actually had to JSON.parse() my getinputdata before passing it to the next phase as the data was a big string.
🙂 1