Hey guys, I have a question about solutions involv...
# suitecommerce
v
Hey guys, I have a question about solutions involving User Event scripts and SC (extensions). We're trying to create/update some custom records when a Sales Order is updated (based on the data that we set in our custom fields on the SO). For that we have a User Event script attached to the SO record. If I update a SO via an extension in SC, will the user event script run synchronously or asynchronously at the back end? (We don't want the SC user to wait while the user event script is running). My understanding is that calling an afterSubmit would be a good way to tackle this situation, but I'm a bit unsure about it.
s
Running a script
beforeSubmit
will force the submission of the record to wait for the outcome of your custom script.
afterSubmit
lets the record finish submission and then fires once complete if set to fire asynchronously.
afterSubmit
is best for performance, but cannot be used to prevent / run validation on a record before it is created
v
Okay. That sounds interesting. Would triggering a separate Map/Reduce script (which has all the business logic) from the User Event script help with performance in this case?
s
It depends what you're trying to do. A map/reduce script is designed for handling either a large amount of data or a large amount of records
v
Thank you. I will go through the document.
I found this section in the article. Then I read about the afterSubmit method in the NS Help section and noticed this note: Asynchronous afterSubmit user events are only supported during webstore checkout. Will that also apply while executing the Commerce API order.submit() method?
s
I assume so as that's probably the method we use to submit an order