How in a clientside script to query the "version" ...
# ask-stanley-ai
a
How in a clientside script to query the "version" field of a transaction record, so the script can tell if the record has been modified while the user has been editing it? Or is there another way to do this? I'm trying to warn the user as soon as the record they're editing gets changed by something else before they click the save button, instead of them losing all their changes to a "Record has been changed" error when they try to save those changes.
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems that there isn't a direct way to query the "version" field of a transaction record in a client-side script. However, there are a few workarounds that you can consider: 1. Custom Field Counter: You can create a custom field that increments every time the record is saved. This would give you a count of how many times the record has been saved, which can be used as a proxy for the version number. 2. SuiteQL Query: You can run a SuiteQL query to get the version number from the transaction history. The query would look something like this:
SELECT version FROM transactionhistory WHERE transaction = 'xxx'
. However, this might not be feasible in a client-side script. 3. Record Locking: To detect if a record is being edited by another user, you can use a custom record as a lock. You can create a custom record for every transaction and check a checkbox on the custom record during beforeLoad to indicate that someone is editing the record. You can then create a warning if someone else tries to edit the transaction while the checkbox is checked. You would also need to uncheck the checkbox on save. 4. Activity Check: You can implement an activity check on an interval to detect when someone edits a transaction and doesn't save. This could be done via a timestamp on the custom record that you can also check to determine if you should show the message. 5. Record Edit Audit: You can create a "record edit audit" that tracks when someone opens a record in edit mode. A client script can then run every few minutes updating the "last alive" time. If the last alive time is more than a certain threshold, it can mark the record as inactive, otherwise, it can pop up a warning saying who is currently editing. Remember, these are workarounds and might not be perfect solutions. You would need to test and adjust them according to your specific use case. ****** 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.874694824
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.851013184
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.850341797
Please provide your feedback on this answer.