YASSER
01/21/2025, 8:30 AMCeligo AI
01/21/2025, 8:30 AMAI generated answer (using internal Slack threads):To create an approval workflow on the invoice if any item rate is below the average cost, you would need to create a SuiteScript that checks the item rate against the average cost. If the item rate is below the average cost, the script would then trigger the approval workflow. Here's a high-level overview of how you could implement this: 1. Create a User Event Script: This script will be triggered whenever an invoice is created or edited. In the script, you would loop through each line item in the invoice and compare the item rate against the average cost. If any item rate is below the average cost, you would set a custom field (e.g., 'Approval Required') on the invoice to 'True'. 2. Create a Workflow: This workflow would be triggered whenever an invoice is created or edited and the 'Approval Required' field is 'True'. The workflow would then send the invoice for approval. Here's a pseudo-code example of what the User Event Script might look like:
javascript
function beforeSubmit(context) {
var record = context.newRecord;
var lineCount = record.getLineCount({sublistId: 'item'});
for (var i = 0; i < lineCount; i++) {
var itemRate = record.getSublistValue({sublistId: 'item', fieldId: 'rate', line: i});
var itemId = record.getSublistValue({sublistId: 'item', fieldId: 'item', line: i});
var itemRecord = record.load({type: 'inventoryitem', id: itemId});
var averageCost = itemRecord.getValue({fieldId: 'averagecost'});
if (itemRate < averageCost) {
record.setValue({fieldId: 'custbody_approval_required', value: true});
break;
}
}
}
Please note that this is a high-level overview and the actual implementation may vary based on your specific requirements and NetSuite setup. You may need to adjust the script and workflow to fit your 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
01/21/2025, 8:31 AMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.834252477
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.825342655
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.823453665
Celigo AI
01/21/2025, 8:31 AM