Hi all! I'm trying to return this object to the ma...
# suitescript
h
Hi all! I'm trying to return this object to the map stage of a Map/Reduce script but I receive nothing in the map stage context. Does anyone have an idea of what's wrong here? I want to map all the items in the map stage. { "items":[ { "arstaArticle":"4012", "sixNumberedArticleId":"2812", "newArstaArticleSelectOption":"2812", "newBasePrice":null, "arstaItemid":"2812", "isMonday":"T", "isThursday":"F", "scriptURL":"/app/site/hosting/scriptlet.nl?script=309&deploy=1&compid=..." }, { "arstaArticle":"4013", "sixNumberedArticleId":"2825", "newArstaArticleSelectOption":"2825", "newBasePrice":null, "arstaItemid":"2825", "isMonday":"T", "isThursday":"F", "scriptURL":"/app/site/hosting/scriptlet.nl?script=309&deploy=1&compid=..." } ] }
b
are you returning the entire object in getInputData, or just the value of items key
h
I'm returning the entire object
l
not sure it support object-array-object, but could be wrong here, but think, array (all elements will be returned) or object (all values per key will be returned)
so return obj.items should work for you
👍 1
h
I have tried returning an array with only the items but that doesn't work either.
l
then im out 😉 that works for me in alot of case, we often just return an array, maybe its cause its json object and no js object, not sure i tried that
so try do a parse on all the objects in the array and see if that works
b
the map context should include an object whose key is the string "items"
and whose value is a string that represents the json form of your items array
as mentioned by Lander, you need to parse the json string value to do anything useful with it
it usually helps to log the context of your map function
h
I parsed the data in getInputData stage and it works but the map context removed the 'items' key and one item from the item array. How should the data be sent to the map context in order to process each item from the item array, in the map stage?
Thank you for the input @battk! This is the correct structure: [ { "item":{ "arstaArticle":"4012", "sixNumberedArticleId":"2812", "newArstaArticleSelectOption":"2812", "newBasePrice":null, "arstaItemid":"2812", "isMonday":"T", "isThursday":"F", } }, { "item":{ "arstaArticle":"4013", "sixNumberedArticleId":"2825", "newArstaArticleSelectOption":"2825", "newBasePrice":null, "arstaItemid":"2825", "isMonday":"T", "isThursday":"F", } } ]
b
you probably want to go over the documentation for mapContext.key and mapContext.value to understand how keys and values work with different types
👍 1
h
Can I return an object from the map stage directly to the summarize stage?
b
the output you get from summaryContext.output does not come from map
h
ok so I have to write or return it to the reduce stage and pass it to the summarize stage?
b
you can write in the map and write in the reduce
but its better to just do your logic in reduce and write in reduce
a
@battk still troubleshooting the SFTP connection here
from the company that hosts the SFTP server, they are asking me about the ip address where the call comes from
is that possible to determine?
b
im very confused about how this is related to the original thread, but the answer is that netsuite wont help you. Take a look at the NetSuite IP Addresses policy
a
sorry, I asked you about this in the wrong thread
but thanks for the info