how to switch this filters into [{"name":"onhand",...
# ask-stanley-ai
n
how to switch this filters into [{"name":"onhand","operator":"greaterthan","values":["0"],"isor":false,"isnot":false,"leftparens":0,"rightparens":0},{"name":"formulatext","operator":"is","values":["24"],"formula":"SUBSTR({inventorynumber.inventorynumber}, LENGTH({inventorynumber.inventorynumber}) - 1, 2)","isor":false,"isnot":false,"leftparens":0,"rightparens":0}] suitescript 2.0
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems like you are trying to add filters to a search in SuiteScript 2.0. Here's how you can do it: First, you need to create an array of filter objects. Each filter object should have the following properties:
name
,
operator
,
values
,
isor
,
isnot
,
leftparens
,
rightparens
, and optionally
formula
if you are using a formula filter. Here's an example of how you can create such an array:
Copy code
javascript
var filters = [
    {
        name: "onhand",
        operator: "greaterthan",
        values: ["0"],
        isor: false,
        isnot: false,
        leftparens: 0,
        rightparens: 0
    },
    {
        name: "formulatext",
        operator: "is",
        values: ["24"],
        formula: "SUBSTR({inventorynumber.inventorynumber}, LENGTH({inventorynumber.inventorynumber}) - 1, 2)",
        isor: false,
        isnot: false,
        leftparens: 0,
        rightparens: 0
    }
];
Then, you can add these filters to your search:
Copy code
javascript
var searchObj = search.create({
    type: "inventoryitem",
    filters: filters
});
Please note that the
formulatext
filter uses a formula to extract the last two characters of the
inventorynumber
field. The
SUBSTR
function is used to achieve this. The
LENGTH
function is used to get the length of the
inventorynumber
field. ****** 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.859923899
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.850768507
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.840313911
Please provide your feedback on this answer.