Ava
05/29/2025, 11:33 PMCeligo AI
05/29/2025, 11:33 PMAI generated answer (using internal Slack threads):To get the vendor name of an item on a purchase order using SuiteScript's n/record module, you would need to load the purchase order record, navigate to the item sublist, and then get the vendor from the itemvendor sublist. Here's a simplified example of how you might do this:
javascript
var record = require('N/record');
// Load the purchase order record
var poRecord = record.load({
type: record.Type.PURCHASE_ORDER,
id: 'your_purchase_order_id'
});
// Get the count of items on the purchase order
var itemCount = poRecord.getLineCount({ sublistId: 'item' });
// Loop through each item
for (var i = 0; i < itemCount; i++) {
// Get the item id
var itemId = poRecord.getSublistValue({
sublistId: 'item',
fieldId: 'item',
line: i
});
// Load the item record
var itemRecord = record.load({
type: record.Type.INVENTORY_ITEM, // or whatever the item type is
id: itemId
});
// Get the count of vendors for the item
var vendorCount = itemRecord.getLineCount({ sublistId: 'itemvendor' });
// Loop through each vendor
for (var j = 0; j < vendorCount; j++) {
// Get the vendor id
var vendorId = itemRecord.getSublistValue({
sublistId: 'itemvendor',
fieldId: 'vendor',
line: j
});
// Load the vendor record
var vendorRecord = record.load({
type: record.Type.VENDOR,
id: vendorId
});
// Get the vendor name
var vendorName = vendorRecord.getValue({ fieldId: 'companyname' });
// Now you have the vendor name
console.log(vendorName);
}
}
Please replace 'your_purchase_order_id' with the actual ID of the purchase order you're interested in. Also, note that this code assumes that the item type is 'inventoryitem'. If the items on your purchase order are of a different type, you'll need to adjust the code accordingly.
******
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
05/29/2025, 11:34 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.830423236
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.826073766
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.824933708
Celigo AI
05/29/2025, 11:34 PM