What is the best way to execute a suitescript when...
# suitescript
s
What is the best way to execute a suitescript when a new sales order has been created? It needs to execute whether that sales order was created manually, through a soap call, through a restlet or scheduled script. Basically ANY time that a new sales order is created. Thanks
b
the usual answer is a user event script
if you really mean anytime, like a sales order created in another workflow or userevent script, then you want a map/reduce or scheduled script
s
I read that user events only trigger on 3 points, load, before submit, after submit. None of which would actually kick off specifically for record creation.
I am not familiar with map/reduce. How would a scheduled script operate? check for new records since the last run?
b
You can filter the event type that a script runs on from the deployment via Setting Script Execution *Event *Type from the UI
its primitive enough that its usually done in the script itself
map/reduce or scheduled scripts would run on a schedule and usually perform logic on the results of a search
there are many ways you can make the records show up in a search, the most basic being a checkbox on the sales order
which you check after doing your processing
s
So if a user event script can run on create for a salesorder record type, is there a reason you would use a scheduled script instead?
would user event not fire if the so creation was by another script or through SOAP
b
How User Events are Executed notes important limitations about user event execution
in general, read the documentation for user event scripts
pay extra attention to anything performance related or error related
s
yes. it says that you can execute a user event script from a scheduled script but it does not indicate if it would fire or not fire automatically if a scheduled script created a sales order.
b
soap requests control if scripts run via the runServerSuiteScriptAndWorkflowTriggers preference
s
to make sure that I get everything I think I will need to do a scheduled script with a flag to mark processed.
thank you
b
message has been deleted