If I want to track the old vs new value of a field...
# ask-stanley-ai
a
If I want to track the old vs new value of a field, can I still do this with a beforeSubmit UE or is afterSubmit the best practice? Either way, the script should only trigger when the field has changed values
c
AI generated answer (using internal Slack threads):
In NetSuite, you can track the old vs new value of a field using both beforeSubmit and afterSubmit User Event (UE) scripts. However, the choice between the two depends on your specific use case. In a beforeSubmit UE, you can prevent a save, easily set field values, and access the old and new values of a field. However, 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. On the other hand, an afterSubmit UE script is triggered after a record is saved. This means that the changes are already committed to the database when the script runs. If you need to perform operations based on the new value of a field after it has been saved, then an afterSubmit script would be more appropriate. In your case, if you want the script to trigger only when the field has changed values, you can use a beforeSubmit script. You can compare the old and new values of the field, and if they are different, perform your operations. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.864257693
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.863464415
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.855896
Please provide your feedback on this answer.