What are the pro(s)/con(s) of using beforeSubmit v...
# suitescript
d
What are the pro(s)/con(s) of using beforeSubmit vs. afterSubmit in a UE script?
I am writing a User Event for item_substitute and making the relationship bi-directional and potentially other changes to the parent item….
The pro I see to beforeSubmit is that I avoid the time cost of a double save
p
They just have different use-cases. You can prevent a save in a
beforeSubmit
, for example, and also easily set field values. Also, it’s not guaranteed that the records will actually save when you do stuff in a
beforeSubmit
- another UE script could stop the save by throwing an exception, so you need to consider that with regard to data consistency if you’re dealing with other records in your scripting
👍 1