Question

How would you go about getting all inventory locations for a particular item? What I would like is to check if a specific inventory location has any allotted inventory for an item.

I have tried to use the nlapiSearchRecord('item',null,filter,columns) to try this but it only returns the preferred location and not all locations even though their is inventory in the other locations.

Filters were setup as such:

filters = [ new nlobjSearchFilter('internalid',null,'is',10)];

If I add new nlobjSearchFilter('location',null,'is',34) to the filters which is the id for the inventory location I am looking for, I don't get any results at all.

the return I get from the above filters only list the preferred location and not any other locations with available inventory.

-- UPDATE --

After updating the code to use the suggestion below I am now getting the inventory location but not the correct inventory count for the location which should be 5 not 87

var itemId = 3376;
var locationId = 34;

var items = [];
var filters = [];
var columns = [];

filters = [
            new nlobjSearchFilter('internalid',null,'is',itemId),
            new nlobjSearchFilter('inventorylocation',null,'is',locationId),
            new nlobjSearchFilter('quantityavailable',null,'greaterthan',0)
        ];

columns = [
           new nlobjSearchColumn('itemid'),
           new nlobjSearchColumn('inventorylocation'),
           new nlobjSearchColumn('quantityavailable'),
           new nlobjSearchColumn('quantityonhand'),
        ];


var results = nlapiSearchRecord('item',null,filters,columns);

if (results != null)
{
    for (var i=0, l=results.length; i < l; i++)
    {
        var result = results[i];

        items.push(result);
    } 
}

OUT PUT printed in JSON Format

{ 
   "id": "3376", 
   "recordtype": "assemblyitem", 
   "columns": { 
      "itemid": "Marketing : Misc : T-Shirt Womens Medium", 
      "inventorylocation": { 
                      "name": "InventoryLocation", 
                      "internalid": "34" 
       }, 
    "quantityavailable": 87, 
    "quantityonhand": 90 
   } 
}

Thanks in advance.

Was it helpful?

Solution

I believe the field to use is the 'inventorylocation' field.

OTHER TIPS

You should use the locationquantityavailable and locationquantityonhand columns instead of the ones you are using.

For references to the available columns/fields on a records, you may lookup the "Records Browser" in Help.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top