In my After Submit User Event script, I am receivi...
# ask-stanley-ai
s
In my After Submit User Event script, I am receiving "error":{"type":"error.SuiteScriptError","name":"THAT_RECORD_IS_NOT_EDITABLE" when trying to perform record.save on the newRecord in scriptContext, while the record is in standard mode. How do I save this record after I have created changes on it?
c
AI generated answer (using internal Slack threads):
The error
THAT_RECORD_IS_NOT_EDITABLE
typically occurs when you're trying to save a record that is already in the process of being saved or has been saved. This can happen if you have multiple scripts running simultaneously that are trying to update the same record, or if you're trying to save a record twice within the same script. In a User Event script, you don't need to explicitly call
record.save()
on the
newRecord
object in the script context. NetSuite automatically saves the changes you make to the
newRecord
object when the script execution is completed. If you try to call
record.save()
on the
newRecord
object, you'll get the
THAT_RECORD_IS_NOT_EDITABLE
error because the record is already in the process of being saved by NetSuite. Here's what you can do to avoid this error: 1. Remove any explicit
record.save()
calls on the
newRecord
object in your After Submit User Event script. Just make the changes you need to the
newRecord
object and let NetSuite handle the saving. 2. If you have multiple scripts running simultaneously that are trying to update the same record, you might need to refactor your code to avoid conflicts. For example, you could consolidate the changes into a single script, or use a different type of script (like a Scheduled script or Map/Reduce script) to handle some of the updates. 3. If you're trying to update a record in an After Submit User Event script, you might need to load the record again before making changes. This is because the
newRecord
object in the script context is read-only in After Submit scripts. Remember, when working with records in User Event scripts, the record is in standard mode, not dynamic mode. This means that changes to field values are immediately saved to the record, and you can't navigate the record's sublists or line items like you can in dynamic mode. ****** 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.861396611
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.860803246
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.857018113
Please provide your feedback on this answer.