Nada Ahmed
12/31/2024, 3:48 PMCeligo AI
12/31/2024, 3:48 PMAI generated answer (using internal Slack threads):To add an approval condition if the sales order lines contain a discount item, you can use a SuiteScript. You can write a User Event script that triggers on the 'beforeSubmit' event of the Sales Order record. This script would loop through each line of the Sales Order and check if any of the lines contain a discount item. If a discount item is found, you can set the approval status of the Sales Order to 'Pending Approval'. Here is a sample code snippet:
javascript
function beforeSubmit(context) {
if (context.type !== context.UserEventType.CREATE && context.type !== context.UserEventType.EDIT) {
return;
}
var salesOrder = context.newRecord;
var lineCount = salesOrder.getLineCount({sublistId: 'item'});
for (var i = 0; i < lineCount; i++) {
var itemId = salesOrder.getSublistValue({
sublistId: 'item',
fieldId: 'item',
line: i
});
var itemType = salesOrder.getSublistValue({
sublistId: 'item',
fieldId: 'itemtype',
line: i
});
// Check if the item is a discount item
if (itemType === 'Discount') {
salesOrder.setValue({
fieldId: 'approvalstatus',
value: 2 // Pending Approval
});
break;
}
}
}
This script checks each line of the Sales Order for a discount item. If a discount item is found, it sets the approval status of the Sales Order to 'Pending Approval'. Please replace 'Discount' with the actual item type of your discount items.
******
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
12/31/2024, 3:48 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.808766782
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.805697381
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.804971099
Celigo AI
12/31/2024, 3:48 PM