how can I search inventoryitem with location id us...
# ask-stanley-ai
s
how can I search inventoryitem with location id using suitescript 2.0
c
AI generated answer (using internal Slack threads):
To search for an
inventoryitem
with a specific
location id
using SuiteScript 2.0, you can use the
N/search
module to create a search. You would need to add a filter to the search to specify the location id. Here is a sample code snippet:
Copy code
javascript
var search = require('N/search');

var inventoryItemSearch = search.create({
   type: search.Type.INVENTORY_ITEM,
   filters: [
      ['location', 'anyof', locationId]
   ],
   columns: ['itemid', 'displayname', 'location', 'locationquantityonhand']
});

inventoryItemSearch.run().each(function(result) {
   // Process each result
   return true;
});
In this code,
locationId
is the id of the location you are interested in. The
filters
array is used to specify the search criteria. The
columns
array is used to specify the fields that you want to retrieve. Please note that the
location
field is a sublist field on the
inventoryitem
record, so you need to use the
anyof
operator in the filter. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.853601098
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.849991918
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.848970294
Please provide your feedback on this answer.