This message was deleted.
# ask-stanley-ai
s
This message was deleted.
c
AI generated answer (using internal Slack threads):
To create a search that shows item inventory on hand by location, you can use SuiteScript's search module. Here is a sample code snippet that creates a search on the item record:
Copy code
javascript
var itemSearchObj = search.create({
   type: "item",
   filters:
   [
      ["locationquantityonhand","greaterthan","0"],
      "AND",
      ["name","is","item"],
      "AND",
      ["inventorylocation.isinactive","is","F"]
   ],
   columns:
   [
      search.createColumn({
         name: "itemid",
         sort: search.Sort.ASC,
         label: "Name"
      }),
      search.createColumn({name: "inventorylocation", label: "Inventory Location"}),
      search.createColumn({name: "locationquantityonhand", label: "Location On Hand"})
   ]
});
var searchResultCount = itemSearchObj.runPaged().count;
log.debug("itemSearchObj result count",searchResultCount);
itemSearchObj.run().each(function(result){
   // .run().each has a limit of 4,000 results
   return true;
});
This script creates a search on the item record with filters for items that have a location quantity on hand greater than 0, are not inactive, and have a specific name. The columns returned in the search results include the item ID, inventory location, and location quantity on hand. Please note that the 'locationquantityonhand' field gives you the quantity on hand for a specific location. If you have many locations, you will see a line for each location. You can restrict this by adding 'Inventory Location' to your criteria. ****** 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.879246414
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.870784879
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.86862272
Please provide your feedback on this answer.