you probably need to share how you are doing your ...
# suitescript
b
you probably need to share how you are doing your filter with this one
n
Copy code
var itemSearch = search.load({
					id: 'customsearch152'
				});

itemSearch.filters.push(
   search.createFilter({
      name: 'trandate',
      operator: 'within',
      values: [d1, d2]
   })
);
where d1 is 1/1/2019 and d2 is 12/31/2019
b
as in they are strings instead of Dates?
n
yes
I tried this new Date(d1) but it thrown an error.
Error as in invalid filter
This filter works though, 1/1/2018 and 12/31/2019... but it does not return any results.
b
what type of search is this?
i dont think its an item search like your variable suggests
n
Yeah, it is a transaction search.
variable says itemsearch because i copied it from another code. Will refactor later.
b
Copy code
require(["N/search", "N/format"], function(search, format) {
  var tranSearch = search.create({ type: search.Type.TRANSACTION , filters: [ search.createFilter({
      name: "trandate",
      operator: "within",
      values: [
        format.format({
          value: new Date("2019-01-01T08:00:00.000Z"),
          type: format.Type.DATE
        }),format.format({
          value: new Date("2019-12-31T08:00:00.000Z"),
          type: format.Type.DATE
        }) 
      ]
    })]});
  var results = tranSearch.run().getRange(0, 1000);
  log.debug("results", results.length);
});
try only adding your one filter and no others
(i used format since its more portable between accounts)
n
Ok, let me try.
No, it didn't work.
b
as in there are no results
or an error
n
Oh... wait...
1 minute.
Sorry, issue resolved. It was wrong variable returning from search method.
Thanks for your help @battk