markus
10/01/2024, 10:42 AMCeligo AI
10/01/2024, 10:42 AMAI generated answer (using internal Slack threads):In order to recognize which transaction lines have been added in an edit via a user event script, you can use the
oldRecord
and newRecord
objects in a beforeSubmit
or afterSubmit
user event. By comparing these two objects, you can identify the changes made to the record, including any new lines that have been added.
Here's a basic example of how you might do this:
javascript
function afterSubmit(context) {
var oldRecord = context.oldRecord;
var newRecord = context.newRecord;
var oldLineCount = oldRecord.getLineCount({sublistId: 'item'});
var newLineCount = newRecord.getLineCount({sublistId: 'item'});
if (newLineCount > oldLineCount) {
// New lines have been added
for (var i = oldLineCount; i < newLineCount; i++) {
var newItem = newRecord.getSublistValue({
sublistId: 'item',
fieldId: 'item',
line: i
});
log.debug('New item added', newItem);
}
}
}
In this example, we're comparing the line count of the 'item' sublist in the old and new records. If the new record has more lines, we know that new lines have been added, and we can loop through these to get the details of the new items.
Please note that this is a simplified example and you may need to adjust it to suit your specific needs.
******
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
10/01/2024, 10:42 AMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.841695309
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.83684957
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.830678284
Celigo AI
10/01/2024, 10:42 AMCeligo AI
10/01/2024, 10:42 AM