2
votes

I'm new to Netsuite and SuiteScripting. I am trying to create a Search in SuiteScript 2.0 that will display Inventory Items based on a few filters. One of the filters I am trying to use is in the items related records. I am able to do this in Netsuite's saved search but need to be able to do it in SuiteScript.

Creating the search criteria in Netsuite:
Creating the search criteria in Netsuite:

The Transaction: Type is Sales Order is what I am trying to copy in SuiteScript.

I tried using the Join tag but that does not seems to change my results at all. The following code will run but does not change the results.

   search.createFilter({
        name: "internalid",
        join: "transaction",
        operator: search.Operator.IS,
        values: 'salesorder'}) ]

If I try to change Name: to "type" it runs but gives no results.

    search.createFilter({
        name: "type",
        join: "transaction",
        operator: search.Operator.IS,
        values: 'salesorder'}) ]

Any help is appreciated.

1

1 Answers

1
votes

I was able to resolve the issue. Using a different syntax for the search. I was able to export the search criteria as SuiteScript with a browser tool.

var SearchResults = search.create({
        type: search.Type.INVENTORY_ITEM,
  filters:
        [
            ["quantityonhand","greaterthan","0"],
            "AND",
            ["isinactive","is","F"],
            "AND",
            ["type","anyof","InvtPart"],
            "AND",
            ["modified","onorbefore","3/3/2018 12:00 am","3/17/2018 11:59 pm"],
            "AND",
            ["transaction.type","anyof","SalesOrd"]
        ],
                columns:["itemid", "internalid", "displayname", "quantityonHand", "isinactive"]
        }).run().getRange({start: 0, end: 1000});