Ava
11/12/2024, 6:49 PMCeligo AI
11/12/2024, 6:50 PMAI generated answer (using internal Slack threads):****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ****** To update the rate of an item on a sales order based on a query when the line is committed, you can use a client script in SuiteScript. Here is a sample code snippet:
javascript
/**
* @NApiVersion 2.x
* @NScriptType ClientScript
* @NModuleScope SameAccount
*/
define(['N/currentRecord', 'N/log', 'N/search'],
function(currentRecord, log, search) {
function postSourcing(context) {
var record = context.currentRecord;
if (context.fieldId == 'quantity' || context.fieldId == 'item') {
var _rate = parseInt(record.getCurrentSublistValue("item", "rate"));
// Update the rate based on your query here
record.setCurrentSublistValue("item", "rate", newRate);
}
}
return {
postSourcing: postSourcing
};
});
In this script, the postSourcing
function is used to update the rate of the item. This function is triggered after a sublist field is set (committed). The new rate is calculated based on your query and then set using setCurrentSublistValue
.
Please replace newRate
with the actual rate you want to set. This rate can be obtained from your query.
Remember to deploy the script and associate it with the Sales Order record type.Celigo AI
11/12/2024, 6:50 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.848462224
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.83952564
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.837748826
Celigo AI
11/12/2024, 6:50 PM