Search code examples
javascriptnetsuitesuitescript2.0

filter on saved search suitescript


I want to make a filter on saved search with the condition that if I press the checkbox (checkbox == T) it will display all items in the invoice provided that one item is included in the item. for example I chose item A01, and on the target invoice, namely invoice INV 001 containing items (A09, A08, and A07) and invoice INV 002 (A01, A02, A03) then the result that will come out is INV 002 with all the items available (because we choose in filter A01)

if (checkbox === true) {
    if (itemId[0] != "") {

        filter.push(
            "AND",
            ["item", "anyof", "item"])
    }
}
else {
    if (itemId[0] != "") {

        filter.push(
            "AND",
            ["item", "anyof", itemId])
    }
}

here I only show all items if the checkbox is true, and displays everything. what is the appropriate way of intercepting?


Solution

  • The filter for this is anylineitem

    so

    filter.push('AND', ['anylineitem', 'is', itemId])