Hi, Does Record.create record instance fire user e...
# suitescript
g
Hi, Does Record.create record instance fire user event script attached to the same record type?
s
Yes, unless you're calling record.create from a user event script.
g
ok, but confusing. Record.create is used in custom lib to create a custom record instance then custom lib is called in Sales Order UE script in SO UE script, call custom lib to create custom record. but the UE script attached to this custom record is not fired. 😫
s
That's expected
Since the custom lib is called from the UE script, it's still considered part of the UE script execution.
g
cool, I was thinking the other way, thank you
s
Do you need the custom record ue script to fire?
g
if it can
s
What's causing the SO UE script to fire?
g
user save SO in UI, SO UE calls custom lib to create custom record in afterSubmit()
s
As long as this is a user saving the SO via the UI, this is a trick you can use:
In the UE aftersubmit, have it use N/redirect to redirect to a suitelet (passing any params you might need). Then, in the suitelet, create the custom record (which will cause UEs to fire) and once done, have the suitelet redirect back to the SO.
If you don't care how quickly the custom records are created, you could also resort to a map reduce script to find SOs that need the custom record(s) to be created.
The suitelet redirect approach works pretty well though
g
Nice to have alternatives. I will trying them late. thank you very much
👍 1