you are running out of goverance, probably doing s...
# suitescript
s
you are running out of goverance, probably doing something extremely inefficient like a search or load for each line, rather than consolidating information and doing a single search.
k
there is no search or anything in the script. literally picks a line, checks some fields in the lines and creates a billing schedule.
s
creates a schedule for each line individually? (I am unfamiliar with billing schedule) I assume that is a record.create() for each line?
k
yes
it seemed to be working fine for all the other orders, this one order is failing. It has around 622 lines and the script is erring out in line 350
s
if it's failing at map, the easiest softest tweak is to call the same function in reduce instead of map, and that'll yield 5k units instead of 1k
k
its failing in reduce
right now, when I hard code the script to loop through the lines in batches, it seems to be working. for eg for-loop 0 to 300, then 300 -500...
s
then you probably need to define your map stages from get input to do a higher record level job
it means that instead of say per record on map, it needs to already be per line on map
k
ahh I see, I wasnt using map in this script at all. so you mean I should pass key-value pair per line from map?
s
so imagine, from getInputData, you're allowed to pass an array (or a search) passing through map will yield +1000 units well in total in addition to reduce if you used context.write correctly suppose you end with context.write) which will pass you to the reduce stage
s
if it's as as simple as create a search in getInput, and pass each line to map, just do it in map and don't use reduce. If you have multiple transactions and want to pass each transaction to map, then pass each line individually to reduce, that would be fine as well.
s
@Sandii if they're getting stuck at reduce, and reduce had 5k units instead of 1k units in map which they're not using, im pretty convinced they need some restructuring
s
yeah you should not be looping lines in reduce
s
@Sandii dont say that, i've seen people manipulate in summary instead of map or reduce.....
k
so right now, I am passing search from getInput and looping each line in reduce, was not using map, and will do that now, to pass each line from map.. and nope not doing anything is summary other than err-handling 😄
s
wait do you know it's actually stopping at getInputData? secondly honestly you might need refactoring or restructuring if 5000 units isn't enough per getInputData instance
s
You don't need to pass each line to the reduce if each line is passed to the map, you likely don't need to use reduce at all if all the information needed is coming from the getInput.
s
I think during this conversation they said map isn't used so i assumed the execution context was just called at reduce after the getInputData
k
the reduce stage currently gets one sales order at a time, and then it would loop through the line
getInput gets Data from a saved search which has individual sales order per line, not individual lines per sales order
b
use your map stage to write individual lines
k
yes sir!
🤣 1