It seems a Close Order button doesn't trigger a Us...
# suitescript
e
It seems a Close Order button doesn't trigger a User Event. How can we detect when a Sales Order is closed?
c
What do you need to do when it closes?
e
Trigger other scripts for a sync with the 3PL as fast as possible
c
In what contexts besides the UI are the sales orders closed?
e
UI only
c
Grubaugh's mention of a custom Close button might be your best bet, especially if you need immediate (ie faster than a 15-minute polling interval) action
b
as fast as possible is a beforeLoad user event script, which is triggered when the user views the sales order after closing it
e
🤔 Wrapping my head about this... beforeLoad doesnt have oldRecord, so I can't differentiate between a Sales Order that was closed yesterday and the one I closed now.
b
you will need to keep track of that yourself
for example a checkbox that you mark after your script runs on a closed order
c
@battk What would you think about using session to manage this? A session value that stores a value related to its closed status. If, when it runs, there's no value and the transaction isn't closed, it sets the value as, for example,
open
. When it runs again during beforeLoad on view after it's been closed, read it -- if the key is defined and the value is set to
open
and the transaction is closed, perform the 3PL operation and remove the session value.
b
i have no idea how you would get that to work, those sessions dont last forever, their lifetime is measured in hours
you would lose state after the session is lost
c
@battk Correct - it would be transitory by design.
As long as the action only needs to take place during the beforeLoad directly after the Sales Order is closed, the state doesn't need to be stored permanently
b
in general i dismiss solutions that can only work once
the error handling required for them is just not worth the effort
👍 1
157 Views