Martin
03/07/2025, 7:50 PMCeligo AI
03/07/2025, 7:50 PMAI generated answer (using internal Slack threads):It seems like you're encountering an error because the system is expecting inventory detail for the item you're trying to create a cash sale for. This is likely because the item is set up to track inventory details such as bin numbers, lot numbers, or serial numbers. In SuiteScript, when creating a cash sale (or any transaction) for an item that requires inventory detail, you need to provide that detail via a sublist subrecord. Here's a simplified example of how you might do this:
var cashSaleRecord = record.create({
type: record.Type.CASH_SALE,
// other cash sale fields...
});
cashSaleRecord.selectNewLine({
sublistId: 'item'
});
cashSaleRecord.setCurrentSublistValue({
sublistId: 'item',
fieldId: 'item',
value: itemId // replace with your item's internal id
});
var inventoryDetailSubrecord = cashSaleRecord.getCurrentSublistSubrecord({
sublistId: 'item',
fieldId: 'inventorydetail'
});
inventoryDetailSubrecord.selectNewLine({
sublistId: 'inventoryassignment'
});
inventoryDetailSubrecord.setCurrentSublistValue({
sublistId: 'inventoryassignment',
fieldId: 'binnumber',
value: binNumber // replace with your bin number
});
// set other necessary inventory detail fields...
inventoryDetailSubrecord.commitLine({
sublistId: 'inventoryassignment'
});
cashSaleRecord.commitLine({
sublistId: 'item'
});
var cashSaleId = cashSaleRecord.save();
This code creates a new cash sale record, selects a new line on the 'item' sublist, sets the 'item' field to the internal id of the item you're selling, gets the 'inventorydetail' subrecord for the current line, selects a new line on the 'inventoryassignment' sublist of the subrecord, sets the 'binnumber' field to your bin number, and then commits the line on both the subrecord and the cash sale record.
Please replace itemId
and binNumber
with your actual item's internal id and bin number.
******
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
03/07/2025, 7:51 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.87113589
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.852468431
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.848695457
Celigo AI
03/07/2025, 7:51 PM