https://netsuiteprofessionals.com logo
#suitescript
Title
# suitescript
s

Sim Greenbaum

03/30/2022, 2:32 PM
I'm trying to create a search of all my assembly in a specific location current inv on hand, the problem I have is my current search only gives me the lot controlled items I need both lot controlled and not lot controlled. but only showing be the current inv on hand and there lot numbers
Copy code
var assemblyitemSearchObj = search.create({
   type: "assemblyitem",
   filters:
   [
      ["type","anyof","Assembly"], 
      "AND", 
      ["inventorylocation.name","startswith","E-Commerce"], 
      "AND", 
      ["locationquantityavailable","greaterthan","0"], 
      "AND", 
      ["inventorynumber.quantityonhand","greaterthan","0"], 
      "AND", 
      ["inventorynumber.location","anyof","14"]
   ],
   columns:
   [
      search.createColumn({
         name: "itemid",
         sort: search.Sort.ASC,
         label: "Name"
      }),
      search.createColumn({name: "description", label: "Description"}),
      search.createColumn({name: "type", label: "Type"}),
      search.createColumn({name: "locationquantityavailable", label: "Location Available"}),
      search.createColumn({
         name: "location",
         join: "inventoryNumber",
         label: "Location"
      }),
      search.createColumn({
         name: "inventorynumber",
         join: "inventoryNumber",
         label: "Number"
      }),
      search.createColumn({
         name: "itemid",
         join: "memberItem",
         label: "Name"
      }),
      search.createColumn({name: "memberquantity", label: "Member Quantity"}),
      search.createColumn({
         name: "quantityonhand",
         join: "inventoryNumber",
         label: "On Hand"
      }),
      search.createColumn({
         name: "islotitem",
         join: "memberItem",
         label: "Is Lot Numbered Item"
      })
   ]
});
var searchResultCount = assemblyitemSearchObj.runPaged().count;
log.debug("assemblyitemSearchObj result count",searchResultCount);
assemblyitemSearchObj.run().each(function(result){
   // .run().each has a limit of 4,000 results
   return true;
});
b

battk

03/30/2022, 2:39 PM
you have 2 filters that expect values that only exist on inventory numbers
s

Sim Greenbaum

03/30/2022, 2:50 PM
i know my problem is how would i write a filter if it is lot controlled apply these filters if not apply these filter
b

battk

03/30/2022, 2:53 PM
your filter expression allows you to use
OR
it allows nested expressions
it allows you to do something like
Copy code
A OR B
or in your case
Copy code
A OR [C AND D AND E]
s

Sim Greenbaum

03/30/2022, 3:00 PM
if I'm in the UI so that would be formula
b

battk

03/30/2022, 3:02 PM
you could, but it wouldnt make it easier
e

ec

03/30/2022, 5:23 PM
@Sim Greenbaum if you can create this in the UI (Saved Search) and save it, use this extension to see what the underlying filter expression would look like https://chrome.google.com/webstore/detail/netsuite-search-export/gglbgdfbkaelbjpjkiepdmfaihdokglp?hl=en-US
s

Sim Greenbaum

03/30/2022, 5:39 PM
Thanks I was having trouble doing it in the ui
b

battk

03/31/2022, 2:00 AM
message has been deleted
s

Sim Greenbaum

04/01/2022, 2:32 PM
thank you