Steve Reeder Steve Reeder - 1 year ago 83
Javascript Question

Suitescript to return a the vendor prices for a selected item

Good evening all, and Merry Christmas!!

I feel like I'm bumping my ass at the sky on this...

I know the vendor prices for each item are in a sublist under each item, but I can't for the life of me figure our how to retrieve said information.

I've tried a search but it just refuses to work.

Likewise I've tried looking for a sublist internal id for search "lines" in the item record, but with no luck. i did read somewhere about an 'itemvendor' sublist, but itemRecord.getItemLineCount('itemvendor') is not recognised.

Any thoughts anyone?



Edit: I was able to achieve the desired result with the following code (basically the same as @Mike Robbins code sample):

var itemRecord = nlapiLoadRecord('inventoryitem',itemID);
var lines = itemRecord.getLineItemCount('itemvendor');
for (var i=1; i <= lines; i++) {
var vendor = itemRecord.getLineItemValue ('itemvendor','vendor',i);
if (vendor == vendorID ) {
i = lines + 1;

Answer Source

You can also do this in a search. The field is vendorcost. Note that if you just use "vendor" instead of 'entityid', 'vendor' you'll get the preferred vendor info:

nlapiSearchRecord('item', null, [
    new nlobjSearchFilter('vendorcost', null, 'greaterthan', 0),
    new nlobjSearchFilter('itemid', null, 'contains', 'cable')
], [
    new nlobjSearchColumn('itemid'),
    new nlobjSearchColumn('entityid', 'vendor'),
    new nlobjSearchColumn('vendorcost')
]).forEach(function(it) {
    console.log(it.getValue('itemid') + ' ' + it.getValue('entityid', 'vendor') + ' ' + it.getValue('vendorcost'));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download