Hi, I have this script that use a filter array. Ho...
# suitescript
t
Hi, I have this script that use a filter array. However, I want the filter to have a "OR" statement at the end. BUT this is not working. Any ideas 🤔
Copy code
filters[0] = new nlobjSearchFilter("type", null, "anyof", 'Custom110') + "AND,";

filters[1] = new nlobjSearchFilter("postingperiod", null, "abs",  "389" ) + "OR";

filters[2] = new nlobjSearchFilter("postingperiod", null, "abs", "390");
s
There's a much easier way to build your filters:
Copy code
filters.push(["type","anyof","Custom110"]);
filters.push("AND");
filters.push([["postingperiod",null,"abs","389"],"OR",["postingperiod",null,"abs","389"]]);
Not sure about null/abs - what are you trying to do there?
t
I just convert this search into script using a google add ons
null are join and abs is the search operator
s
With this plugin your can click a link to see the "scripted" version of your current search
It's an incredible time-saver for scripting searches... build it in the UI and get the code for it
Copy code
filters.push(["type","anyof","Custom110"]);
filters.push("AND");
filters.push([["postingperiod","anyof","389"],"OR",["postingperiod","anyof","390"]]);
That should do the trick
Expressions are much easier than using the
new nlobjSearchFilter
t
Yeah I couldn't agree more on the add ons. However, my plan is to get the posting period dynamically that is why I wanted to isolate the filter per index array
s
just use variables in the search
🤔 1
t
BTW, still getting an error on the script you shares sadblob
s
you don't need the OR then. Pass an array of internal ids into a function
Copy code
var accounts = ["389","390"];

filters.push(["type","anyof","Custom110"]);
filters.push("AND");
filters.push(["postingperiod","anyof",accounts]);
Try this method (if it's a transaction search)
Copy code
var accounts = ["389","390"];

filters.push(["type","anyof","Custom110"]);
filters.push("AND");
filters.push(["postingperiod.internalid","anyof",accounts]);
t
this one actually works thankyou so much!!!
🙌 1
🎉 1
s
no problem