Nour Khaled
05/13/2025, 10:46 AMCeligo AI
05/13/2025, 10:46 AMAI generated answer (using internal Slack threads):In SuiteScript, you can get the list of changed fields on the event by comparing the oldRecord and newRecord. This can be done in a User Event Script. Here is a basic example of how you can do this:
javascript
function afterSubmit(context) {
var newRecord = context.newRecord;
var oldRecord = context.oldRecord;
var fieldNames = newRecord.getFields();
fieldNames.forEach(function(fieldName) {
var oldValue = oldRecord.getValue(fieldName);
var newValue = newRecord.getValue(fieldName);
if(oldValue !== newValue) {
log.debug('Field Changed', 'Field: ' + fieldName + ' Old Value: ' + oldValue + ' New Value: ' + newValue);
}
});
}
In this example, we are getting all the field names from the newRecord, and then for each field, we are getting the old value from the oldRecord and the new value from the newRecord. If the old value is not equal to the new value, we log a debug message indicating the field that changed, the old value, and the new value.
For sublist level changes, you can use a Client Script and the fieldChanged event. Here is an example:
javascript
function fieldChanged(context) {
var currentRecord = context.currentRecord;
var sublistName = context.sublistId;
var sublistFieldName = context.fieldId;
var line = context.line;
if (sublistName === 'item' && sublistFieldName === 'item') {
currentRecord.setValue({
fieldId: 'memo',
value: 'Item: ' + currentRecord.getCurrentSublistValue({
sublistId: 'item',
fieldId: 'item'
}) + ' is selected'
});
}
}
In this example, we are checking if the sublist name is 'item' and the sublist field name is 'item'. If they are, we set the value of the 'memo' field to a string indicating the item that was selected.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
05/13/2025, 10:46 AMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.841349125
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.838485897
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.836552083
Celigo AI
05/13/2025, 10:46 AM