Hello can any one help me out I have a sales orde...
# suitescript
a
Hello can any one help me out I have a sales order with 128 line items and i want to calculate commission on each line item ,when i loop through each line it loop only till 98 lines and stops I tried to loop in descending order from 128 to 0 again it stops on 30 that means from 128 till 20 it only processing not 97 lines can any one help me out how to process all 128 lines
b
you may want to check your logs for errors
inefficient scripts can run out of governance points on many line items
a
Ok sir thanks for help let me check
Copy code
Script Execution Usage Limit Exceeded
This is the error i am getting Can you please help me out sir
b
SuiteScript Governance and Limits is where you want to start
your script is using too many points and you will have to make it more efficient
a
Ok sir thanks i ll definitely look into it
e
if you describe exactly what you need done and perhaps when it needs to be done (or in what context) we can help design that
a
I have a So of more then 120 lines ok There is a column call commission I have to calculate commission on amount and set on commission column but it only calculate till 97 lines and throw error of usage limit exceeds (means governance unit exceeds) because in map reduce Map stage has only 1000 governance unit)
b
you will likely need to share the code if you wish to receive specific advice about how you can reduce your points usage
a
sure sure
mr_calculate_commission.js
b
primary offender on points is how you use getAccount
you pass it one item at a time and it does one search per item
do better, pass it an array of all the items and do a search for all of them
there are variations of doing this better, like using N/cache to just search all of your items once to share with each map
a
Ok ok sure sir i try to apply this