Hey all, wondering if anyone has any advice for de...
# suitescript
z
Hey all, wondering if anyone has any advice for dealing w/ a Restlet script that is consuming too many units? Was trying to have it submit a map/reduce script but having issues
b
the generics are to write the code more efficiently, get the sender to send less data to process, or to use a map/reduce
really depends on what the code looks like
z
Thanks that makes sense, in this case it's a single transaction record that has to be populated with enough items to cause the usage to exceed, so it doesnt automatically yield
b
that sounds like option 1, code it more efficiently
z
Thinking I will change to a scheduled script and make it recursive and call itself when governance units are low, keeping track of where the previous call finished
b
you are unlikely to get a scheduled script to work rescheduling itself over one record
scheduled scripts running out of points tend to just start over
which doesnt help if there is only one record
z
True yeah it needs to be explicitly done. I have done something similar, setting a field on the transaction to record the current index (of search results)
Before each call, the record saves, and then the function pulls this field to know where to start or resume iterating
b
@battk "scheduled scripts running out of points tend to just start over" does it really start over or...? So at this moment I'm looking for a way to process some vendors and based on the governance units I'm able to process just 384 vendors. Each iteration in my current logic takes 26 units. I'm looking for a design pattern to make sure that, when needed, more than 384 vendors can be processed. Do you have any suggestions?
b
first attempt should have been a map/reduce
scheduled scripts generally work by doing a search or query for records to process, processing them and then marking record as processed so it no longer appears in the search results, then when out of points, start over by creating another task
the records that were processed before should no longer appear in the initial search or query and the new task should process new records
b
Alright, thanks! So obvious as always