While editing a transaction line amount, the total...
# ask-stanley-ai
t
While editing a transaction line amount, the total of the transaction was changed. How do I get the value of the new total in a script.
c
AI generated answer (using internal Slack threads):
In order to get the new total of a transaction after editing a line amount in a script, you can use the
getValue
method on the transaction record object. This method allows you to retrieve the value of a field on the record. In this case, you would want to retrieve the value of the 'total' field, which represents the total amount of the transaction. Here is a sample code snippet that demonstrates this:
Copy code
javascript
var transactionRecord = record.load({
    type: record.Type.SALES_ORDER, 
    id: '123'
});

// Edit the line amount here...

// After editing, get the new total
var newTotal = transactionRecord.getValue({
    fieldId: 'total'
});

log.debug({
    title: 'New Total',
    details: newTotal
});
In this example,
record.load
is used to load the transaction record you want to edit. After editing the line amount,
getValue
is used to retrieve the new total of the transaction. The new total is then logged to the script execution log for debugging purposes. Please note that you need to replace
'123'
with the actual internal ID of the transaction record you want to edit. ****** 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.84644562
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.836766481
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.836702406
Please provide your feedback on this answer.