is there access to oldrecord in an xedit user even...
# ask-stanley-ai
e
is there access to oldrecord in an xedit user event?
c
AI generated answer (using internal Slack threads):
In a User Event script, the
oldRecord
object is accessible in both
beforeSubmit
and
afterSubmit
events. However, in the context of an XEDIT event, the
newRecord
object only contains the fields that were changed. This is because XEDIT is triggered when inline editing is performed on a record, and only the modified fields are included in the
newRecord
. If you need to access fields that weren't changed during an XEDIT event, you have two main options: 1. Use the
oldRecord
object: This object will contain the values of the record before the changes were made. If a field wasn't changed during the XEDIT event, its value in the
oldRecord
will be the current value. 2. Load the record or use a lookup: If you need to access fields that weren't changed and aren't included in the
oldRecord
, you can load the record or use a lookup to get the current values of these fields. Here is an example of how you can use the
oldRecord
in a User Event script:
Copy code
javascript
function afterSubmit(context) {
    var oldRecord = context.oldRecord;
    var field1Value = oldRecord.getValue('field1');
    // ...
}
Remember, the
oldRecord
object is not available in
beforeLoad
events. Also, be aware that loading a record or performing a lookup can have performance implications, especially if you're dealing with a large number of records or fields. ****** 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.817688048
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.807373106
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.80719
Please provide your feedback on this answer.