Imran Hasan
12/27/2024, 3:12 PMCeligo AI
12/27/2024, 3:12 PMAI generated answer (using internal Slack threads):To get an item class using a UserEvent script from a sales order item line, you can use the
getCurrentSublistValue
method of the record
module in SuiteScript 2.0. Here is a sample code snippet:
javascript
/**
* @NApiVersion 2.x
* @NScriptType UserEventScript
* @NModuleScope SameAccount
*/
define(['N/record', 'N/search'],
function(record, search) {
function beforeSubmit(context) {
var newRecord = context.newRecord;
var numLines = newRecord.getLineCount({ sublistId: 'item' });
for (var i = 0; i < numLines; i++) {
var itemId = newRecord.getSublistValue({
sublistId: 'item',
fieldId: 'item',
line: i
});
var itemRecord = record.load({
type: record.Type.INVENTORY_ITEM, // replace with the appropriate item type
id: itemId
});
var itemClass = itemRecord.getValue({ fieldId: 'class' });
// Now you have the item class, you can use it as needed
// ...
}
}
return {
beforeSubmit: beforeSubmit
};
});
This script loads each item on the sales order line by line, then gets the class of the item. Please replace record.Type.INVENTORY_ITEM
with the appropriate item type if you are dealing with a different type of item.
Remember to deploy the script and set the deployment to execute on the Sales Order record type.
******
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/27/2024, 3:12 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.814432383
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.797577679
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.797524631
Celigo AI
12/27/2024, 3:12 PM