SunShine
01/28/2025, 4:48 AMCeligo AI
01/28/2025, 4:48 AMAI generated answer (using internal Slack threads):Based on the conversations, it seems like you want to create a client script that checks if a customer's balance is greater than 1000 and if so, does not allow a sales order with an amount greater than 500 to be created. This can be achieved using SuiteScript's
saveRecord
function.
Here is a sample code snippet that might help you:
javascript
/**
* @NApiVersion 2.x
* @NScriptType ClientScript
*/
define(['N/record', 'N/currentRecord'], function(record, currentRecord) {
function saveRecord(context) {
var currentRec = currentRecord.get();
var customerId = currentRec.getValue({
fieldId: 'entity'
});
var customerObj = record.load({
type: record.Type.CUSTOMER,
id: customerId
});
var customerBalance = customerObj.getValue({
fieldId: 'balance'
});
var salesOrderTotal = currentRec.getValue({
fieldId: 'total'
});
if (customerBalance > 1000 && salesOrderTotal > 500) {
alert('Cannot create sales order. Customer balance is greater than 1000 and sales order total is greater than 500.');
return false; // prevent the sales order from being saved
}
return true;
}
return {
saveRecord: saveRecord
};
});
This script first gets the current record and the customer ID. It then loads the customer record to get the customer's balance. It also gets the total of the current sales order. If the customer's balance is greater than 1000 and the sales order total is greater than 500, it alerts the user and prevents the sales order from being saved.
******
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
01/28/2025, 4:48 AMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.819529355
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.812629223
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.810878217
Celigo AI
01/28/2025, 4:48 AM