Is it a good practice to offput an async operation...
# suitescript
s
Is it a good practice to offput an async operation on an afterSubmit to offload it to a suitelet? I can either use a scheduled map/reduce to go back in and run my business logic or I can call a suitelet in the after submit. Thoughts?
b
Yeah, if the logic can wait it's better to just use the aftersubmit to set a checkbox to true so it can be processed later in a batch job. Even better if you can avoid the afterSubmit and just run a search instead for records to process by last modified date or some other criteria. It's best practice to try to process the data in scheduled batches as much as possible to give priority to critical real time operations.
b
offloading to a suitelet is unlikely to be any faster
your after submit will still wait for the https request to finish even if you use a Promise
s
oof. I was hoping to offload it and let the after submit just continue on. Thanks
s
You can offfload it using a scheduled script. As long as you don't actually call the scheduled from the aftersubmit.