so the map/reduce script just hits a governance li...
# suitescript
c
so the map/reduce script just hits a governance limit while it's running - all they've been doing for the past few months is manually executing the script again whenever they get an error saying it's hit a limit
b
well, if that worked, a minor bit of effort should be able to turn that into a scheduled script that can reschedule itself
c
The getInputData method calls a search method then does searchMethod().run().each(function(result) { }
and all of the logic is in that call back
What I could do is put all of the search results into an array then pass that array to the map function?
Otherwise yeah, a scheduled script that reschedules itself
b
if its as nice as you say, you return searchMethod() in your getInputData
c
The script takes a field value from a long list of sales orders then copies that value into a shopify order via https.post
b
and rewrite the each callback as the map
c
one value for each SO, saved search usually has about 900 records by the end of the day it seems
Yeah that sounds good - I'll look at refactoring the each callback into the map function. That should stop it from hitting a limit and actually use map / reduce properly. Thanks!
Can I literally just refactor it like this?
b
no
probably want to go through the docs of map/reduce more closely
the search returned from getInputData is transformed into key/value pairs
each key/value is passed to your map function
c
Thanks, I'm reading more into how I can refactor this into a proper map/reduce pattern,
b
its why i said the minor effort is the scheduled script that reschedules itself