Map / Reduce - possible to use global variables or...
# suitescript
n
Map / Reduce - possible to use global variables or not? Double checking before I get in a mess 😉 Thanks.
n
No. It will be a mess
Been there and what I did what set the values in the deployment parameter and then read back on each iteration. Performance wa spoor than a Scheduled because of that.
n
I don't mean a constant, I mean a global, it's something I want to update within the getInputData step but I have two functions outside that I call that make use of the global. I guess I'll have to pass the JSON in to my function each time I call it to update it. Thanks for replying @Nik
e
@NElliott From my experience it seems that Global Variables does not exist through the life cycle of the four stages in a map reduce. They are like different contexts. So if you set something in the geInput stage, then if you do not pass that value in your array/json to the map state, the value will not exist or be accessible, even if it is a Global Variable. Hopefully it makes sense.
n
Thanks for the replies guys. I'm only interested in using it in the getInputData section. I'm off for the holiday period now but will try what I have in mind and if I remember, report back 🙂 Essentially I'm looking at this kind of structure: var thetable = {}; function something(some,thing){ thetable[some] = thing; } getInputData(){ for(){ something(abc,def); } // use theTable to define my output to the map } So it's just to allow me to access the table inside the getInputData stage but be accessible to the functions I'm calling from within that stage.
(and to clarify that's not the actual functions / logic / process but just the general format)